Skip to content

refactor(legacy_expr): step γ2 — SketchAgg un-fusion bridge - #143

Merged
zzylol merged 1 commit into
mainfrom
refactor/legacy-expr-step-gamma2-sketchagg
May 12, 2026
Merged

zzylol merged 1 commit into
mainfrom
refactor/legacy-expr-step-gamma2-sketchagg

Conversation

@zzylol

@zzylol zzylol commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Step γ2 of the legacy_expr α→β→γ→Z migration. Adds a one-way bridge from legacy_expr::QueryExpr::SketchAgg { op, col, .. } → canonical-shape BridgedAggregate for consumers that want positional-column / single-aggregate-list pattern-matching.

Companion to γ1 (Aggregate bridge) — SketchAgg's single-intent / single-column shape collapses onto the same BridgedAggregate carrier with having: None, so consumers don't have to branch on which legacy variant the data originated from.

What's in

  • controller/src/intent_algebra/sketch_agg_bridge.rs (+327) — bridge_sketch_agg_to_canonical(op, col, &Schema) -> Result<BridgedAggregate, BridgeError> plus output_schema_for_sketch_agg thin wrapper over γ1's output_schema_for_aggregate
  • controller/src/intent_algebra/mod.rs (+11) — pub mod + re-exports
  • controller/src/physical/allocator.rs (+54 / -9) — γ2 demo wire: appends a no-op canonical-view suffix to each of the 5 SketchAgg routing arms' rationale strings

Semantics

  • Wildcard → empty by (global semantics)
  • Named / SampleValue[resolve_column_ref(col)]
  • having is hard-coded None (SketchAgg has no HAVING)
  • op passes through verbatim — Step α F1 fan-out happens at parse time before SketchAgg construction

Reuses γ1's BridgedAggregate and BridgeError types — γ2 only ever produces the Key variant.

Test plan

  • cargo build --release -p controller clean
  • cargo test --release -p controller --lib — 715 passed (707 baseline + 8 new γ2 tests)
  • cargo test --release -p controller --bins — 27 passed
  • No behavior change: legacy variant remains in legacy_expr.rs; γ7 retires it later

🤖 Generated with Claude Code

One-way `legacy_expr::QueryExpr::SketchAgg { op, col, .. }` → canonical
`Aggregate { by, aggs }` view via the new `sketch_agg_bridge` module.
Reuses γ1's `BridgedAggregate` carrier and `BridgeError` since SketchAgg
and Aggregate produce structurally-identical canonical shapes.

`Wildcard` → empty `by` (global semantics); `Named`/`SampleValue` →
`[resolve_column_ref(col)]`. `having` is hard-coded `None`. The legacy
variant remains in legacy_expr.rs until Step γ7 retires it.

Wired into `physical/allocator.rs::alloc_sketch_agg` as a no-op rationale
suffix on all 5 routing arms (Avg→Db, Exact→Backend, Sketch→Agent/
Backend/Precompute) — proof of canonical-view consumption without
behavior change.

8 new unit tests; cargo build + cargo test green (696 controller-lib /
27 controller-bins passing).
@zzylol
zzylol merged commit 07cb12d into main May 12, 2026
@zzylol
zzylol deleted the refactor/legacy-expr-step-gamma2-sketchagg branch July 17, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant