Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Native from_json with a schema that repeats a field name fails with "ArrowArray struct has 2 children (expected 1)"

オープン 初心者向け
#6,592 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Samearth17 がすでに取り組んでいます。

2026年10月5日 から。

  • #6651 @Samearth17 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
scala
領域
backend

調査の方向性

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 の本文から書いたものです。

説明

area:expressions area:ffi bug good first issue priority:medium
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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/datafusion-comet のほかの issue

apache/datafusion-comet の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。