Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions control_plane/src/intent_algebra/expr_ir.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//! Language-independent scalar expression IR.
//!
//! ## Phase 2 step 2 (docs/migration-plan-backend-plan.md)
//!
//! New file, re-exported from ASAPController's `asap-ir` crate. This is
//! the D2 decision from `ASAPController/docs/intent-algebra-reconciliation.md`
//! (already validated by ASAPController's own evolution — control_plane
//! had no equivalent generic-over-column-type scalar IR before this):
//! `Predicate` and `HavingPredicate` in `query_expr.rs` are currently ad
//! hoc, control_plane-only types; `relational.rs`'s `ScalarExpr` is a
//! separate, L2-only scalar type. Once `query_expr.rs`/`relational.rs`
//! are merged (next Phase 2 step), both collapse onto this one
//! `Expr<C>` — `L2Expr = Expr<ColumnRef>` for the front-end-emitted L2
//! tree, `L3Expr = Expr<ColumnId>` for the canonical positional L3 tree.
//! Nothing in this repo constructs `Expr<C>` yet — that lands with the
//! `query_expr.rs`/`relational.rs` merge, not here. This step only makes
//! the type available.
//!
//! One generic [`Expr<C>`] spans the lowering boundary; the two layers are
//! aliases that differ only in the column-reference type `C`:
//!
//! - [`L2Expr`] = `Expr<ColumnRef>` — name-based. The per-language front ends
//! emit it (PromQL label matchers, SQL `WHERE` / projection / sort-key
//! expressions) on the Layer-2 `relational` tree.
//! - [`L3Expr`] = `Expr<ColumnId>` — **positional**. The canonical L3
//! `query_expr` tree carries it; the converter resolves every `ColumnRef`
//! against the in-scope schema to produce it, so L3 column identity is
//! unambiguous (no name collisions across a join).
//!
//! `Expr<C>` shares the scalar/operator vocabulary
//! ([`L3Scalar`], [`CompareOp`], [`ArithOp`]) — the **union** of what the two
//! front ends need: PromQL contributes `Regex` / `NotRegex` (`=~` / `!~`); SQL
//! contributes arithmetic, `CASE`, `IN`, `CAST`, `IS [NOT] NULL`, scalar
//! function calls, and the `LIKE` / `ILIKE` comparison family.

pub use asap_ir::intent_algebra::{ArithOp, ColumnRef, CompareOp, Expr, L2Expr, L3Expr, L3Scalar};
6 changes: 6 additions & 0 deletions control_plane/src/intent_algebra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@

pub mod agg_intent;
pub mod cse;
// Not yet re-exported into the crate::intent_algebra::* top-level surface
// below -- `query_expr::ColumnRef` already claims that name, and this
// module is unused until the query_expr.rs/relational.rs merge (next
// Phase 2 step) retargets `Predicate`/`ScalarExpr` onto `L3Expr`/`L2Expr`.
// Reachable today only via the full `intent_algebra::expr_ir::` path.
pub mod expr_ir;
pub mod query_expr;
pub mod schema;

Expand Down