Repository navigation
Commit f9e2eb2
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.
Registers the config and rule in the generated artifacts that enumerate
every setting and optimizer rule: configs.md, information_schema.slt,
optimizer_rule_reference.md, and the EXPLAIN VERBOSE rule list in
explain.slt.
Closes apache#23602. Part of apache#23600; the struct fast path depends on apache#23628.1 parent 18b1e35 commit f9e2eb2
11 files changed
Lines changed: 626 additions & 4 deletions
File tree
- datafusion
- common/src
- core/src
- optimizer
- src
- sqllogictest/test_files
- docs/source/user-guide
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 | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
| 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