[Bug] format_string panics when the format argument is a NULL-typed column
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
Direzione di ricerca
Inizia da crates/spark/src/function/string/format_string.rs, soprattutto dal percorso degli array intorno alle righe 202–209, dove l’issue segnala la mancata gestione di NULL. Controlla il comportamento scalare esistente per NULL e l’esempio di sqllogictest in crates/sqllogictest/test_files/string/format_string_null_format.slt; l’issue indica il comando da eseguire per quel test. Il lavoro è completato quando le colonne di formato tipizzate come NULL restituiscono NULL per ogni riga senza causare un panic, anche tramite l’alias printf.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Rust
- Stelle
- 13
- Fork
- 31
- Merge medio
- 2g 2h
- PR unite (30g)
- 96
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/datafusion-spark
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 84/100
apache/datafusion-spark#440 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
apache/datafusion-spark#439 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] width_bucket returns NULL for an infinite valueForse già presa @vaidik787 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/datafusion-spark#424 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] format_string with %#e puts the decimal point after the exponentForse già presa @vaidik787 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
apache/datafusion-spark#423 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] parse_url ignores the key for a part other than QUERY, Spark returns NULLForse già presa @Aryan2210 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
apache/datafusion-spark#409 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/datafusion-spark
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
foundry-rs/starknet-foundry#4733 ·
I maintainer di solito rispondono entro 4 giorni
-
autofix:working
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
libracoder/kiri#1138 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno