Commit 93a2167
feat: widen marginalization to almost all window queries
One rule decides everything: a window is marginalizable iff its value
is a function of row-visible values — the partition keys plus, when
ORDER BY discriminates, the order values (RANGE/GROUPS peers share
values). Newly admitted: running aggregates and RANGE/GROUPS frames
(order values join the key set), whole-partition frames, the rank
family, first_value/last_value/nth_value, FILTER, DISTINCT and ordered
arguments inside aggregates, IGNORE NULLS on value functions,
expression partition/order keys (joined by the qualified expression),
COLLATE order keys (stripped to the raw child so multiplicity holds),
and named windows (inlined by the oracle's parser for free).
The aggregate allowlist is gone: the two-stage fit reruns the original
computation, so any WINDOW_AGGREGATE — including order-sensitive ones —
freezes exactly the value the original text produced.
Still refused, each with a named error: row_number, ntile, lag, lead,
bounded ROWS frames, EXCLUDE, non-constant frame bounds — physical
position is the one thing a join key cannot carry.
Gate: training-set round-trip invariant over the widened surface,
2000-case seeded fuzz bit-exact; the gate comparison is now NaN-aware
and signed-zero-strict (corr produces NaN, and pyarrow equals says
NaN != NaN).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 1e859da commit 93a2167
5 files changed
Lines changed: 458 additions & 120 deletions
File tree
- docs/superpowers/specs
- packages/sql-transform
- sql_transform
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
0 commit comments