`rand` and `randn` with an integer seed fall back to Spark without a fallback reason
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
spark/src/main/scala/org/apache/comet/serde/nondetermenistic.scala から始め、seeded rand と randn のサポート確認が extractSeedFromExpr とどのように関係するかを追ってください。issue に記載された、解析後の IntegerType と LongType のシードを比較し、関連する変換テストを確認してください。integer シードが long シードと同様に変換されるか、具体的な fallback 理由を生成し、厳密な fallback チェックに合格すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
A Project or Filter that contains rand(<int>) or randn(<int>), for example rand(42), is
not converted, and Comet records no fallback reason on the operator or on any of its expressions.
In SQL, an integer literal seed such as rand(42) has type IntegerType. Only a LongType
seed, such as rand(42L), is converted.
With spark.comet.explain.fallback.strict.enabled=true, which CometTestBase turns on for
Comet's own suites, the query fails with:
java.lang.IllegalStateException: Comet did not convert Filter but recorded no fallback reason on
the operator or any of its expressions. Add a withFallbackReason call stating why conversion
failed.
(or ... did not convert Project ... for a projection). Without the strict check, the only
reason shown is the generic "<operator> is not supported" from
CometExecRule.reportUnexplainedFallback, which does not say what to change.
Steps to reproduce
Run on main (0f7f8e453) with the default profile (Spark 4.1.3), in a CometTestBase suite:
spark.range(0, 200, 1, numPartitions = 1)
.selectExpr("CAST(id AS INT) AS id", "IF(id % 3 = 0, NULL, CAST(id AS INT)) AS y")
.write.parquet(path)
spark.read.parquet(path).createOrReplaceTempView("t")
These four queries each fail with the error above:
SELECT id FROM t WHERE y IS NOT NULL AND rand(42) < 0.5;
SELECT id FROM t WHERE abs(rand(42)) < 0.5;
SELECT id, rand(1) AS r FROM t;
SELECT id, randn(1) AS r FROM t;
The same queries with a Long seed are converted:
| Query | Executed plan |
|---|---|
SELECT id FROM t WHERE y IS NOT NULL AND rand(42L) < 0.5 |
CometProject > CometFilter > CometNativeScan |
SELECT id FROM t WHERE abs(rand(42L)) < 0.5 |
contains CometFilter |
SELECT id, rand(1L) AS r FROM t |
CometProject |
SELECT id, randn(1L) AS r FROM t |
CometProject |
In the analyzed plans, the seed of rand(1) and rand(42) is IntegerType, and the seed of
rand(1L) is LongType.
Cause
In spark/src/main/scala/org/apache/comet/serde/nondetermenistic.scala, the seeded serde's
getSupportLevel returns Compatible() for any Literal seed. But CometRand.convert and
CometRandn.convert build the proto from extractSeedFromExpr:
protected def extractSeedFromExpr(expr: Expression): Option[Long] = {
expr match {
case Literal(seed: Long, _) => Some(seed)
case Literal(null, _) => Some(0L)
case _ => None
}
}
An IntegerType literal matches neither case, so convert returns None without recording a
reason.
Expected behavior
rand and randn with an integer literal seed are converted, as they are with a Long seed.
Spark accepts an IntegerType or LongType seed and widens an integer seed to a long
(RDG.seed in Spark's randomExpressions.scala). If an integer seed is not supported,
the conversion should record a fallback reason that says so.
Additional context
A possible fix: accept an Int literal in extractSeedFromExpr and widen it to a Long, or have
getSupportLevel reject what convert cannot take, with a reason.
🤖 Generated with Claude Code
- 主要言語
- Scala
- スター
- 1.3k
- フォーク
- 405
- 平均マージ
- 3日 6時間
- マージ済み PR(30日)
- 239
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion-comet のほかの issue
-
area:writer enhancement requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
apache/datafusion-comet#7463 ·
メンテナーはふだん 2 日以内に返信
-
requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-comet#7458 ·
メンテナーはふだん 2 日以内に返信
-
requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion-comet#7453 ·
メンテナーはふだん 2 日以内に返信
-
area:ci enhancement priority:low requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
apache/datafusion-comet#7319 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
area:ci bug priority:low requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-comet#7315 ·
メンテナーはふだん 2 日以内に返信
apache/datafusion-comet の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
canton-network/splice#8342 ·
メンテナーはふだん 1 日以内に返信
-
bug genc
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
`estimateTip` caps the estimated tip at 2147483647対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
software-mansion/starknet-jvm#644 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
propensive/soundness#2424 ·
メンテナーはふだん 1 日以内に返信
-
? - Needs Triage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
NVIDIA/cudf-spark#16741 ·
メンテナーはふだん 1 日以内に返信