Native from_json with a schema that repeats a field name fails with "ArrowArray struct has 2 children (expected 1)"
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
CometJsonToStructs.isSupportedSchema から始めます。これはフィールド型を検証しますが名前は検証しません。この失敗は NativeUtil.importVector で表面化します。Java Arrow が struct の子を名前でキー付けするためです。任意の深さでフィールド名が重複した struct を拒否する再帰チェックを追加し、クエリが dispatcher にフォールバックするようにします。dispatcher はすでにそれらを拒否しています(#5766)。また、レポートの SQL を使って JsonToStructs テストスイートでカバーします。完了とは、from_json(j, 'a INT, a INT') が IllegalStateException をスローする代わりに Spark の {null, 1} を返すことを意味します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With the native from_json path enabled (spark.comet.expression.JsonToStructs.allowIncompatible=true), a schema that repeats a field name fails the task once the result reaches the JVM. Spark accepts such a schema and fills the last field with that name, so from_json('{"a":1}', 'a INT, a INT') returns {null, 1}. Comet's native projection builds the same struct, and to_json over it matches Spark, but importing the result on the JVM fails because Java Arrow keys struct children by name:
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.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:236)
By default from_json runs through the codegen dispatcher, which declines structs with repeated field names (#5766), so only the opt-in native path is affected.
Steps to reproduce
Reproduced on main at fef94f6cd with Spark 4.1.3:
SET spark.comet.expression.JsonToStructs.allowIncompatible=true;
CREATE TABLE tj (j STRING) USING parquet;
INSERT INTO tj VALUES ('{"a":1}'), ('{"a":2,"b":3}'), (NULL);
SELECT from_json(j, 'a INT, a INT') FROM tj; -- IllegalStateException
SELECT to_json(from_json(j, 'a INT, a INT')) FROM tj; -- matches Spark
SELECT from_json(j, 'a INT, b INT') FROM tj; -- matches Spark
The plan is CometProject over CometNativeScan.
Expected behavior
Either match Spark or stay off the native path. CometJsonToStructs.isSupportedSchema checks the field types but not the names. If it rejected a struct with repeated field names at any depth, these schemas would go to the dispatcher, which already declines them, and the query would fall back to Spark.
Additional context
This is the same Java Arrow limitation as #6591 (struct casts) and #6251 (arrays_zip). Found while checking whether anything in #5603 was worth keeping.
- 主要言語
- Scala
- スター
- 1.3k
- フォーク
- 383
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 419
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion-comet のほかの issue
-
Iceberg data tables whose names end with a metadata-table name fall back to Spark対応中かも @aryan9948 が今日担当しました。 オープンrequires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/datafusion-comet#6719 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ANSI integral SUM overflow reports "integer overflow" without Spark's try_add suggestion対応中かも @0lai0 が 1 日前に担当しました。 オープンarea:aggregation bug priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/datafusion-comet#6661 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Casting to a struct type with repeated field names fails with "ArrowArray struct has 2 children (expected 1)"対応中かも @Samearth17 が 2 日前に担当しました。 オープンarea:expressions area:ffi bug good first issue priority:high
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/datafusion-comet#6591 ·
メンテナーはふだん 1 日以内に返信
-
arrays_zip with two same-named inputs fails with "ArrowArray struct has 2 children (expected 1)"対応中かも @mohitgurav20 が 8 日前に担当しました。 オープンarea:expressions area:ffi bug priority:high
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-comet#6251 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
ci: a transient Maven Central failure in lint-java is reported as a scalafix violation対応中かも @andygrove が 17 日前に担当しました。 オープンarea:ci bug priority:low
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
apache/datafusion-comet#6060 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion-comet の issue をすべて見る
似ている issue
-
withMaxHeaderSize is not applied to HTTP/2 since h2c support in 0.7.2 (431 Request Header Fields Too Large)対応中かも @rbos-dhl が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
http4s/http4s-netty#1028 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
area/map-site bug layer/core size/S
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
marola-dev/marola-app#60 ·
メンテナーはふだん 1 日以内に返信
-
enhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
lambdaworks/zio-elasticsearch#863 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信