Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#6,592 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Samearth17 ya está trabajando en esto.

Desde el 5/10/2026.

  • #6651 de @Samearth17 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
scala
Área
backend

Línea de trabajo

Comienza en CometJsonToStructs.isSupportedSchema, que valida los tipos de campo pero no los nombres; el fallo se manifiesta en NativeUtil.importVector porque Java Arrow indexa los hijos de los struct por nombre. Añade una comprobación recursiva que rechace los struct con nombres de campo repetidos a cualquier profundidad, de modo que la consulta recurra al dispatcher, que ya los rechaza (#5766), y cúbrelo en la suite de pruebas de JsonToStructs con el SQL del informe. Hecho significa que from_json(j, 'a INT, a INT') devuelve el {null, 1} de Spark en lugar de lanzar IllegalStateException.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Scala
Estrellas
1.3k
Forks
387
Merge medio
2 d 5 h
PR fusionados (30 d)
413

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/datafusion-comet

Todos los issues de apache/datafusion-comet

Issues similares

Más issues de Scala

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.