Skip to content

feat(sql): plan joins over summary children - #370

Merged
zzylol merged 6 commits into
mainfrom
codex/sql-join-recursive
Sep 10, 2026
Merged

feat(sql): plan joins over summary children#370
zzylol merged 6 commits into
mainfrom
codex/sql-join-recursive

Conversation

@zzylol

@zzylol zzylol commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Why

A SQL join was retained as one KeepPreAsap subtree, so temporal aggregate children on each side could not independently bind to reusable summaries. For example, joining two grouped asap_rate(...) subqueries forced the complete join through exact execution.

What

  • Add a language-neutral SummaryExpr::RelationalJoin to the post-ASAP IR and executable DAG.
  • Recursively plan both sides of supported inner column-equality joins.
  • Preserve join kind, predicate, grouping boundaries, output schema, and strict execution data-state validation.
  • Keep unsupported outer joins and predicate shapes as local exact residuals.
  • Finalize exact accumulator state into the canonical readable schema before query-time composition.
  • Export the whole-graph validator's authoritative edge state instead of deriving it twice.

How

Bottom-up binding plans each join input independently, then emits a relational node only when both inputs and the predicate satisfy the typed contract. DAG validation checks operator payloads, schemas, grouping, and execution phases before export. Exact accumulator finalization restores the original pre-ASAP value types, so downstream joins and aggregates consume rows rather than opaque state.

Before

A join over two summary-capable temporal aggregates remained one exact subtree.

After

Each temporal aggregate can bind independently, and the read-time join composes their typed results in the same post-ASAP DAG. Unsupported children remain exact without replacing supported siblings.

Verification

  • cargo fmt --all -- --check
  • cargo test -p asap-types post_asap::executable_dag
  • cargo test -p asap-integration-tests --test promql_to_post_asap
  • Full workspace CI

@zzylol
zzylol force-pushed the codex/sql-join-recursive branch from 16c3658 to 516cb8d Compare September 10, 2026 17:30
@zzylol
zzylol changed the base branch from feat/sql-temporal-aggregates to main September 10, 2026 17:30
@zzylol zzylol changed the title Plan relational joins over summary children feat(sql): plan joins over summary children Sep 10, 2026
@zzylol
zzylol merged commit 3dda280 into main Sep 10, 2026
4 checks passed
zzylol added a commit that referenced this pull request Sep 10, 2026
* feat(sql): plan joins over summary children (#370)

* Plan relational joins over summary children

* Test relational join safety boundaries

* Validate relational join input boundaries

* Classify relational joins in DAG viewer

* fix: finalize exact state as readable values

* fix: export validated edge data states

* feat(sql): lower temporal and histogram planning bridges

* fix(sql): validate planning bridge projections
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