arrays_zip with two same-named inputs fails with "ArrowArray struct has 2 children (expected 1)"
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
CometArraysZip.getSupportLevel から始め、そのチェックを CometCreateNamedStruct.getSupportLevel と比較します。Issue にある 3 つの arrays_zip クエリを再現し、その後、重複するフィールド名が JVM Arrow import に到達するのではなく fallback に切り替わるようにします。arrays_zip(a, b) が引き続きネイティブに実行され、同じ名前の 2 つのケースが import error なしで Spark と一致することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
arrays_zip over two inputs with the same name fails the task when Comet runs it natively. Spark names each struct field after its input, so arrays_zip(a, a) has type array<struct<a: string, a: string>>, and Comet's native projection returns that struct fine. Importing the result on the JVM then fails, because Java Arrow keys struct children by name and the two a children collapse into one:
java.lang.IllegalStateException: ArrowArray struct has 2 children (expected 1)
at org.apache.arrow.util.Preconditions.checkState(Preconditions.java:562)
at org.apache.arrow.c.ArrayImporter.doImport(ArrayImporter.java:92)
at org.apache.arrow.c.ArrayImporter.importChild(ArrayImporter.java:83)
at org.apache.arrow.c.ArrayImporter.doImport(ArrayImporter.java:101)
at org.apache.arrow.c.ArrayImporter.importArray(ArrayImporter.java:68)
at org.apache.arrow.c.ArrowImporter.importVector(ArrowImporter.java:62)
at org.apache.comet.vector.NativeUtil.importVector(NativeUtil.scala:264)
at org.apache.comet.vector.NativeUtil.getNextBatch(NativeUtil.scala:211)
at org.apache.comet.CometExecIterator.getNextBatch(CometExecIterator.scala:237)
arrays_zip(a, b) over the same table works. Spark returns the zipped rows for all three queries below.
This is the same Java Arrow limitation as #1015 and #5605. CometCreateNamedStruct.getSupportLevel already returns Unsupported when names has duplicates, and DataTypeSupport rejects such structs in operator schemas, but CometArraysZip.getSupportLevel only checks the input types and never looks at expr.names. Two same-named inputs come up naturally after a join, for example arrays_zip(t1.tags, t2.tags).
Steps to reproduce
Default configs, reproduced on main at f7952de73 with Spark 4.1.3:
spark.range(4)
.selectExpr("id", "array(cast(id as string), 'x') as a", "array(id, id + 1) as b")
.write.parquet(path)
val df = spark.read.parquet(path)
df.selectExpr("id", "arrays_zip(a, a) AS r").collect() // IllegalStateException
df.selectExpr("id", "arrays_zip(b, b) AS r").collect() // IllegalStateException
df.selectExpr("id", "arrays_zip(a, b) AS r").collect() // matches Spark
The plan is CometProject over CometNativeScan.
Expected behavior
Either match Spark or fall back. The smallest fix is probably for CometArraysZip.getSupportLevel to return Unsupported when expr.names has duplicates, the same way CometCreateNamedStruct does.
Additional context
Found while reviewing #6036, but unrelated to that PR's change.
- 主要言語
- Scala
- スター
- 1.3k
- フォーク
- 377
- 平均マージ
- 2日 9時間
- マージ済み PR(30日)
- 272
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion-comet のほかの issue
-
area:ci bug priority:low
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
apache/datafusion-comet#6060 ·
メンテナーはふだん 1 日以内に返信
-
requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/datafusion-comet#5661 ·
メンテナーはふだん 1 日以内に返信
-
requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/datafusion-comet#5601 ·
メンテナーはふだん 1 日以内に返信
-
area:scan enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
apache/datafusion-comet#5319 ·
メンテナーはふだん 1 日以内に返信
-
area:ci priority:low
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
apache/datafusion-comet#4586 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion-comet の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
lichess-org/lila#21826 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
ergoplatform/ergo#2579 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
apache/texera#8682 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
x:action/improve x:size/tiny x:type/content
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信