LEAD/LAG with offset 0 and IGNORE NULLS returns the default for a NULL row, unlike the form without IGNORE NULLS
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Bereich
- backend-api-design, databases
Rechercherichtung
Read datafusion/functions-window/src/lead_lag.rs, focusing on WindowShiftEvaluator::evaluate and the offset-zero path in evaluate_all_with_ignore_null. Start by checking the existing window function tests for LEAD and LAG with IGNORE NULLS; add coverage for offset 0 on a NULL current row. Done means both functions preserve NULL instead of returning the default, with the tests passing.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
lead(v, 0, d) and lag(v, 0, d) return the current row's own value. Without IGNORE NULLS a NULL row stays NULL. With IGNORE NULLS the default d replaces it.
To Reproduce
SELECT id,
lead(v, 0, -7) OVER (ORDER BY id) AS lead_plain,
lead(v, 0, -7) IGNORE NULLS OVER (ORDER BY id) AS lead_ignore_nulls,
lag(v, 0, -7) OVER (ORDER BY id) AS lag_plain,
lag(v, 0, -7) IGNORE NULLS OVER (ORDER BY id) AS lag_ignore_nulls
FROM (VALUES (1, 10), (2, NULL), (3, 30)) AS t(id, v)
ORDER BY id;
On 55.2.0 (datafusion-python 55.0.0):
| id | lead_plain | lead_ignore_nulls | lag_plain | lag_ignore_nulls |
| 1 | 10 | 10 | 10 | 10 |
| 2 | NULL | -7 | NULL | -7 |
| 3 | 30 | 30 | 30 | 30 |
Expected behavior
Row 2 should be NULL in all four columns. Offset 0 refers to the current row itself, so there is no row to skip and nothing out of range that would call for the default. Apache Spark 4.0 returns the row's own value (NULL) for lead(v, 0, -7) IGNORE NULLS, the same as without IGNORE NULLS.
Additional context
In datafusion/functions-window/src/lead_lag.rs the two code paths disagree on this input as written:
evaluate_all_with_ignore_nullstarts withif offset == 0 { return Ok(Arc::clone(array)) }, so a NULL stays NULL.WindowShiftEvaluator::evaluateends with "Set the default value if ... ignore nulls mode and current value is null", which turns a NULL current row into the default when the offset is 0.
Offsets of 1 or more are not affected by this; the offset 0 case is only reached by an explicit 0.
Separately, #25471 (fixed on main by #25472) covers LEAD with an offset of 2 or more returning wrong rows across NULL gaps. The published 55.2.0 crate still has the old code for that.
- 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