lpad/rpad do not use withNullShortCircuit, so ANSI errors are raised on rows Spark skips
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- scala, spark
調査の方向性
lpad/rpad のシリアライザは spark/src/main/scala/org/apache/comet/serde/strings.scala(568〜620行目付近)の CometStringLPad と CometStringRPad です。QueryPlanSerde.scala の withNullShortCircuit と、arrays.scala でそれがどう使われているかを読み、同じ方法で両方のプロトを包んでください。再現コードの NULL 入力に ANSI キャストを適用したとき、lpad と rpad が NULL を返し、そのケースを対象とした SQL ファイルテストがあれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
CometStringLPad and CometStringRPad build their native expression with scalarFunctionExprToProto and do not wrap it in withNullShortCircuit:
- https://github.com/apache/datafusion-comet/blob/8f4ce5e643e9c10803369dae6a1646195f36cb72/spark/src/main/scala/org/apache/comet/serde/strings.scala#L568-L620
withNullShortCircuit: https://github.com/apache/datafusion-comet/blob/8f4ce5e643e9c10803369dae6a1646195f36cb72/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala#L1408
In Spark, StringLPad / StringRPad are TernaryExpressions with nullIntolerant = true. TernaryExpression.eval evaluates the len and pad children only when str is non-null. Comet evaluates all children for every row, so when a child can fail (for example an ANSI cast), Comet can raise an error on a row where str is NULL and Spark would have returned NULL without evaluating that child.
This came up in review of https://github.com/apache/datafusion-comet/pull/7450: https://github.com/apache/datafusion-comet/pull/7450#discussion_r4511335598
Steps to reproduce
Found by reading the code; I have not run this repro yet.
SET spark.sql.ansi.enabled=true;
CREATE TABLE tbl(s STRING, t STRING) USING parquet;
INSERT INTO tbl VALUES (NULL, 'abc');
SELECT lpad(s, CAST(t AS INT)) FROM tbl;
SELECT rpad(s, CAST(t AS INT)) FROM tbl;
Expected behavior
Both queries return NULL, as Spark does, because s is NULL and Spark never evaluates CAST(t AS INT) for that row. Comet is expected to raise a cast error instead.
Additional context
Other serdes already use withNullShortCircuit for this (for example in arrays.scala, maps.scala and datetime.scala). The fix is probably to wrap the lpad/rpad proto in withNullShortCircuit and add a SQL file test for the case above.
Willingness to contribute
I can contribute a fix for this bug independently
- 主要言語
- Scala
- スター
- 1.3k
- フォーク
- 414
- 平均マージ
- 3日 5時間
- マージ済み PR(30日)
- 210
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion-comet のほかの issue
-
bug priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
apache/datafusion-comet#7559 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
area:writer bug priority:low
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-comet#7558 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-comet#7557 ·
メンテナーはふだん 2 日以内に返信
-
`rand` and `randn` with an integer seed fall back to Spark without a fallback reason対応中かも @galaxytemple が 3 日前に担当しました。 オープンrequires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-comet#7479 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
area:writer enhancement requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
apache/datafusion-comet#7463 ·
メンテナーはふだん 2 日以内に返信
apache/datafusion-comet の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
chipsalliance/rocket-chip#3845 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
メンテナーはふだん 13 日以内に返信
-
gesticulate: the `FastInfoset` suffix is written `fast-infoset`, not the registered `fastinfoset`オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
propensive/soundness#2437 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ergoplatform/ergo#2918 ·
メンテナーはふだん 3 日以内に返信