Native from_json with a schema that repeats a field name fails with "ArrowArray struct has 2 children (expected 1)"
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 70/100
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
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
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/datafusion-comet
-
Iceberg data tables whose names end with a metadata-table name fall back to SparkPosiblemente ocupada @aryan9948 la tomó hace 3 días. Abiertorequires-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/datafusion-comet#6719 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ANSI integral SUM overflow reports "integer overflow" without Spark's try_add suggestionPosiblemente ocupada @0lai0 la tomó hace 3 días. Abiertoarea:aggregation bug priority:medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/datafusion-comet#6661 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Casting to a struct type with repeated field names fails with "ArrowArray struct has 2 children (expected 1)"Posiblemente ocupada @Samearth17 la tomó hace 4 días. Abiertoarea:expressions area:ffi bug good first issue priority:high
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/datafusion-comet#6591 ·
Los mantenedores suelen responder en 1 día
-
arrays_zip with two same-named inputs fails with "ArrowArray struct has 2 children (expected 1)"Posiblemente ocupada @mohitgurav20 la tomó hace 11 días. Abiertoarea:expressions area:ffi bug priority:high
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/datafusion-comet#6251 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
ci: a transient Maven Central failure in lint-java is reported as a scalafix violationPosiblemente ocupada @andygrove la tomó hace 19 días. Abiertoarea:ci bug priority:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
apache/datafusion-comet#6060 ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/datafusion-comet
Issues similares
-
Fix Math.ceilDiv wrong result for exact positive divisionsPosiblemente ocupada @pamod-madubashana la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
scala-native/scala-native#5094 ·
Los mantenedores suelen responder en 1 día
-
"Show threat" doesn't show the evaluation of the threatPosiblemente ocupada @Zinkelburger la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
lichess-org/lila#22008 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
C21 publishes `reactivemongo/core/SSL` as Java 23 bytecode — TLS connections fail on any JDK < 23Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
ReactiveMongo/ReactiveMongo#1520 ·
Los mantenedores suelen responder en 1 día
-
module: memory type: bug/reported
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
OpenXiangShan/XiangShan#6688 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
disneystreaming/smithy4s#2011 ·