[Bug] format_string panics when the format argument is a NULL-typed column
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
Línea de trabajo
Empieza en crates/spark/src/function/string/format_string.rs, especialmente en la ruta de arrays alrededor de las líneas 202–209, donde el issue señala que falta gestionar NULL. Comprueba el comportamiento escalar existente para NULL y el ejemplo de sqllogictest en crates/sqllogictest/test_files/string/format_string_null_format.slt; el issue indica el comando para ejecutar esa prueba. El trabajo estará hecho cuando las columnas de formato tipadas como NULL devuelvan NULL en cada fila sin provocar un panic, también a través del alias printf.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
format_string panics with internal error: entered unreachable code when the format argument is a column of type NULL, for example a VALUES column that only holds NULL. Spark casts such a column to STRING and returns NULL for every row.
return_field_from_args accepts DataType::Null (format_string.rs#L108) and the scalar path returns NULL for ScalarValue::Null (#L134). The array path has no case for it: try_as_str() returns None and reaches unreachable!() (#L202). The match on the result type after the loop has no NULL arm either (#L209).
To Reproduce
SELECT format_string(f, a) FROM (VALUES (NULL, CAST(1 AS INT)), (NULL, CAST(2 AS INT))) AS t(f, a);
datafusion-spark panics:
panicked at crates\spark\src\function\string\format_string.rs:202:30:
internal error: entered unreachable code
A NULL literal format (format_string(NULL, CAST(1 AS INT))) and a NULL STRING column both return NULL, so only a NULL-typed column fails. The printf alias panics the same way.
sqllogictest file with Spark's results (fails today)
Save it as crates/sqllogictest/test_files/string/format_string_null_format.slt and run cargo test -p datafusion-spark-sqllogictest -- format_string_null_format. Today both modes fail with the panic.
query T
SELECT format_string(f, a) FROM (VALUES (NULL, CAST(1 AS INT)), (NULL, CAST(2 AS INT))) AS t(f, a);
----
NULL
NULL
Expected behavior
As in Spark:
NULL
NULL
Spark versions
Spark 4.2.0, from the source; not run on a live Spark. FormatString is ImplicitCastInputTypes and declares STRING for the format (stringExpressions.scala#L2066-L2068). A NULL-typed argument is cast to the expected type (TypeCoercion.scala#L202; with ANSI mode on, Cast.scala#L389), and a NULL format gives NULL (stringExpressions.scala#L2080-L2083). Spark accepts a NULL-only VALUES column, as in its own test sql-tests/inputs/group-by.sql. 3.5.8, 4.0.4 and 4.1.3 have the same logic.
datafusion-spark version
main at ab9d308
Additional context
Reproduced on main ab9d308 with the sqllogictest runner in simplify and evaluate mode, and with datafusion-spark-cli with ANSI mode on and off. unreachable!() panics in release builds too.
cc @andygrove
- Lenguaje dominante
- Rust
- Estrellas
- 13
- Forks
- 31
- Merge medio
- 2 d 2 h
- PR fusionados (30 d)
- 96
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-spark
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
apache/datafusion-spark#440 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
apache/datafusion-spark#439 ·
Los mantenedores suelen responder en 1 día
-
[Bug] width_bucket returns NULL for an infinite valuePosiblemente ocupada @vaidik787 la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/datafusion-spark#424 ·
Los mantenedores suelen responder en 1 día
-
[Bug] format_string with %#e puts the decimal point after the exponentPosiblemente ocupada @vaidik787 la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
apache/datafusion-spark#423 ·
Los mantenedores suelen responder en 1 día
-
[Bug] parse_url ignores the key for a part other than QUERY, Spark returns NULLPosiblemente ocupada @Aryan2210 la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
apache/datafusion-spark#409 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/datafusion-spark
Issues similares
-
autofix:working
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
libracoder/kiri#1138 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
roc-lang/basic-webserver#277 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
samkerrcode/opengent#113 ·
Los mantenedores suelen responder en 1 día
-
app bug session
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día