`split_part` with position 0 errors on a NULL string only when the position is a literal
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Bereich
- backend, databases, testing-qa
Rechercherichtung
Start with datafusion/functions/src/string/split_part.rs, especially the fast path and the array path identified in the issue, then review the expr.slt case around the reported test. Decide how the fast path should behave when every string is NULL, using the stated PostgreSQL strictness expectation and the prior review discussion as context. Update the regression test to reflect the chosen behavior and verify the literal and column position cases agree.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
split_part(s, delimiter, 0) on a row where s is NULL returns NULL when the position comes from a column, and errors with "field position must not be zero" when the position is a literal. The fast path for an array string with a scalar delimiter and position rejects position 0 before it looks at any row. The array path skips rows where any argument is NULL, so it errors only on a row whose three arguments are all non-NULL. The two paths disagree whenever no row has a non-NULL string, such as a batch whose strings are all NULL.
To Reproduce
-- Literal delimiter and position: the fast path
SELECT split_part(s, '.', 0) AS r FROM (VALUES (NULL::text)) AS t(s);
-- Execution error: field position must not be zero
-- The same row with the position from a column: the array path
SELECT split_part(s, '.', p) AS r FROM (VALUES (NULL::text, 0)) AS t(s, p);
-- NULL
-- Only literals
SELECT split_part(NULL::text, '.', 0) AS r;
-- NULL
Expected behavior
All three return NULL. PostgreSQL's split_part is strict: its pg_proc entry leaves proisstrict at its default of true, so a NULL argument returns NULL without calling the function.
expr.slt expects the first query's error ("Position 0 with column input errors even for empty/null inputs"), while the review of #21238 asked for the fast path to match the array path (discussion_r3030106101). Which behavior is intended? If it is NULL, the fast path could return all NULLs when the string array has no valid row before checking the position, and the expr.slt case would expect NULL.
Additional context
Property-based tests found this on main at 14b3edd9a3: calling split_part with an array string and scalar delimiter and position gave an error, and the same call with every argument as an array gave NULL. The reproduction runs on main at 14b3edd9a3. The fast path came with #21238.
- Vorherrschende Sprache
- Rust
- Sterne
- 9.6k
- Forks
- 2.6k
- Ø Merge
- 3 T. 4 Std.
- Gemergte PRs (30 T.)
- 345
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/datafusion
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/datafusion#27315 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
apache/datafusion#27094 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlEvtl. vergeben @jonasHanhan hat das vor 9 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
apache/datafusion#27059 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsEvtl. vergeben @joseph-isaacs hat das vor 10 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/datafusion#27050 ·
Maintainer antworten meist innerhalb von 1 Tag
-
physical-plan: decoding an Unnest or Explain node with an unset field panicsEvtl. vergeben @geoHeil hat das vor 8 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
apache/datafusion#26999 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in apache/datafusion
Ähnliche Issues
-
P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
HerringtonDarkholme/hd-lang#1770 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
jonathanong/no-mistakes#3332 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
swc-project/swc-next-issues#310 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
swc-project/swc-ai-issues#653 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
lbjlaq/Antigravity-Manager#3937 ·
Maintainer antworten meist innerhalb von 1 Tag