Repository navigation
Commit 523abfd
committed
feat(optimizer): coalesce peer first_value / last_value into a single struct aggregate
Add the CoalesceFirstLast logical optimizer rule, gated behind
optimizer.enable_coalesce_first_last (default off). Peer first_value /
last_value aggregates that share an ORDER BY key are rewritten into one
struct-valued aggregate plus a get_field projection, so the input is
scanned once instead of once per expression and one per-group state slot
is kept instead of N.
Skips DISTINCT / FILTER / IGNORE NULLS, expressions without an ORDER BY,
and grouping-set aggregates, and no-ops when named_struct / get_field are
not registered.
Closes apache#23602. Part of apache#23600; the struct fast path depends on apache#23628.1 parent f151c10 commit 523abfd
7 files changed
Lines changed: 614 additions & 0 deletions
File tree
- datafusion
- common/src
- optimizer
- src
- sqllogictest/test_files
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1390 | 1390 | | |
1391 | 1391 | | |
1392 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
1393 | 1401 | | |
1394 | 1402 | | |
1395 | 1403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
0 commit comments