`lpad` and `rpad` with a literal length above `i32::MAX` error on a NULL string or fill
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 77/100
Rechercherichtung
Beginne in datafusion/functions/src/unicode/pad.rs und vergleiche den schnellen Pfad für skalare Längen mit der NULL-Behandlung im Array-Pfad. Prüfe die vorhandenen Fälle in string_literal.slt und die im Issue erwähnte verwandte Korrektur für split_part. Fertig ist es, wenn lpad und rpad bei übergroßen literalen Längen für Zeilen mit einem NULL-String oder NULL-Füllwert NULL zurückgeben, bei Zeilen, in denen die relevanten Argumente nicht NULL sind, aber weiterhin einen Fehler auslösen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
lpad(s, n) on a row where s is NULL and n is above i32::MAX errors when n is a literal, and returns NULL when n comes from a column. A NULL fill behaves the same, and so does rpad. The fast path for a scalar length rejects a length above i32::MAX before it looks at any row. The array path skips rows where any argument is NULL before it checks the length, so it errors only on a row whose string and fill are both non-NULL.
To Reproduce
-- Literal length: the fast path
SELECT lpad(s, 2147483648) AS r FROM (VALUES (NULL::text)) AS t(s);
-- Execution error: lpad requested length 2147483648 too large, maximum allowed length is 2147483647
-- The same row with the length from a column: the array path
SELECT lpad(s, n) AS r FROM (VALUES (NULL::text, 2147483648)) AS t(s, n);
-- NULL
-- A NULL fill with a literal length
SELECT lpad(s, 2147483648, f) AS r FROM (VALUES ('a', NULL::text)) AS t(s, f);
-- Execution error: lpad requested length 2147483648 too large, maximum allowed length is 2147483647
-- The same row with the length from a column
SELECT lpad(s, n, f) AS r FROM (VALUES ('a', 2147483648, NULL::text)) AS t(s, n, f);
-- NULL
The same four queries with rpad give the same results.
Expected behavior
All four return NULL, as the array path does. string_literal.slt already expects NULL for a NULL string or fill with a literal length in range, and #27352 made split_part's fast path return NULL in the same situation (#27276).
Could the fast path skip a length above i32::MAX, as it already skips one above MAX_SCALAR_TARGET_LEN, instead of returning the error? The array path would then return the error for the first row whose string and fill are non-NULL, and NULL for the other rows.
Additional context
Property-based tests found this on main at e2dc8b048b: one row of a call with an array of lengths returned NULL, and the same row called with every argument as a scalar returned the error. The reproduction runs on main at e2dc8b048b. The check in the fast path came with #20657 and moved to pad.rs in #26367.
- Vorherrschende Sprache
- Rust
- Sterne
- 9.6k
- Forks
- 2.6k
- Ø Merge
- 3 T. 5 Std.
- Gemergte PRs (30 T.)
- 352
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
-
`verify-release-candidate.sh` version check doesn't catch `-dev` versions and is skipped on macOSEvtl. vergeben @vinycalves hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/datafusion#27563 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
`MoveTowardsLeafNodes` placement implies speculative evaluation, but the docs don't say soEvtl. vergeben @Inf1mum hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
apache/datafusion#27487 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Window constructors panic when the expression list is emptyEvtl. vergeben @abp002 hat das vor 4 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/datafusion#27315 · 3 Kommentare · 1 zugewiesene Person ·
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 15 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
apache/datafusion#27059 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in apache/datafusion
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
tinystream-dev/tinystream#132 ·
-
contract good first issue testing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Emmyt24/nova-launch#2436 ·
Maintainer antworten meist innerhalb von 1 Tag