refactor(legacy_expr): step γ3 — WindowedAgg un-fusion bridge - #142
Merged
Merged
Conversation
Per design.md §3 line ~48 + §6 "What was removed" row 2: "One canonical
form per plan — no `WindowedAgg` (use `Window` over `Aggregate`)".
Follows γ1's strategy (c): keep legacy `QueryExpr::WindowedAgg`
variant in place; provide a canonical-view helper consumers call on
demand. No construction-site rewrites; window-sketch lifecycle
invariant preserved.
```rust
pub fn bridge_windowed_agg_to_canonical(
agg: &AggIntent,
window: &WindowSpec,
col: &LegacyColumnRef,
parent_schema: &Schema,
) -> Result<BridgedWindowedAgg, BridgeError>;
pub fn output_schema_for_windowed_agg(
input: &Schema, by: &[ColumnId], aggs: &[AggIntent],
) -> Schema;
```
`BridgedWindowedAgg { window_kind, window_size, window_slide, inner: BridgedAggregate }`
— stacks γ1's `BridgedAggregate` as the inner Aggregate layer.
Inner `by = vec![col_id]`, `aggs = vec![agg.clone()]`, `having = None`.
Legacy `Tumbling/Sliding/Session` map to canonical `WindowKind`.
`Unbounded`/`Landmark` defer via `BridgeError::UnsupportedWindowKind`.
Rationale (documented in module doc-comment): WindowedAgg fuses TWO
canonical layers (Window over Aggregate). Mixing single-layer and
stacked-layer bridges in one file would dilute each surface. γ1's
`BridgedAggregate` is `pub`-imported and reused as a field — no
duplication.
- happy path (tumbling/sliding/session)
- unbounded/landmark → defer
- Named col resolution; SampleValue
- unknown col / Wildcard → ResolveError
- output_schema strip time, carry by + agg cols, drop out-of-range ids
- end-to-end round-trip through output_schema_helper
`physical/allocator.rs::alloc_node`'s `WindowedAgg` arm calls the
bridge after recursing into `input`. On success, appends
"canonical view: Window(kind=…, size=…, slide=…) over
Aggregate(by_len=…, intent=…)" to `node.annotation.rationale`.
Legacy emit shape unchanged — `alloc_sketch_agg` still receives
`agg`/`col` and emits `QueryExpr::SketchAgg`. The window-sketch
lifecycle invariant is preserved.
- `cargo build --release -p controller` — clean
- `cargo test -p controller --lib` — **700 passed** (was 688 post-γ1;
+12 new windowed_agg_bridge tests)
- `cargo test -p controller --bin controller` — 27 passed
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zzylol
force-pushed
the
refactor/legacy-expr-step-gamma3-windowedagg
branch
from
May 12, 2026 01:23
67a120a to
d7b9125
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per design.md §3 + §6 "What was removed" row 2: "One canonical form per plan — no
WindowedAgg(useWindowoverAggregate)".Follows γ1's strategy (c): keep legacy
QueryExpr::WindowedAggin place; provide a canonical-view helper consumers call on demand. Window-sketch lifecycle invariant preserved — no construction-site rewrites.New:
windowed_agg_bridge.rs(567 lines, 12 tests)BridgedWindowedAgg { window_kind, window_size, window_slide, inner: BridgedAggregate }— stacks γ1'sBridgedAggregateas the inner Aggregate layer.Legacy
Tumbling/Sliding/Session→ canonicalWindowKind.Unbounded/Landmarkdefer viaBridgeError::UnsupportedWindowKind.File placement: separate module
Rationale: WindowedAgg fuses TWO canonical layers (Window over Aggregate). Mixing single-layer + stacked-layer bridges in one file dilutes each surface. γ1's
BridgedAggregateispub-imported as a field — no duplication.Demo wire
physical/allocator.rs::alloc_nodeWindowedAgg arm calls the bridge after recursing intoinput. Appends"canonical view: Window(kind=…, size=…, slide=…) over Aggregate(by_len=…, intent=…)"toNodeAnnotation.rationale. Legacy emit + lifecycle unchanged.Build + test
cargo build --release -p controllercleancargo test -p controller --lib— 700 passed (was 688 post-γ1; +12 new tests)cargo test -p controller --bin controller— 27 passedDiff: 3 files, +627 / -2
🤖 Generated with Claude Code