Skip to content

Eliminate L2Expr/L3Expr as a separate scalar-expression type; fold into QueryExpr, generic over column-reference state #205

Description

@zzylol

Summary

L2Expr/L3Expr (crates/types/src/intent_algebra/expr_ir.rs) are one generic scalar-expression tree, Expr<C>, aliased twice:

  • L2Expr = Expr<ColumnRef> — name-based, front-end-emitted.
  • L3Expr = Expr<ColumnId> — positional, produced by the Binder resolving every ColumnRef against the in-scope schema.

They're a separate type family from the canonical QueryExpr operator tree, only reachable through it via wrapper fields: Scan.predicates: Vec<Predicate>, Filter.pred: Predicate(L3Expr), Aggregate.having: Option<Predicate>, Project.items: Vec<ProjectItem { expr: L3Expr, .. }>, Sort.keys: Vec<SortKey { expr: L3Expr, .. }>, and BinaryOp's scalar operand.

Proposal

Drop the separate Expr<C> family. Fold its variants (Column/Literal/Compare/BoolAnd/BoolOr/Not/IsNull/IsNotNull/Cast/InList/FunctionCall/Arith/Case) directly into QueryExpr, and make QueryExpr itself generic over the column-reference type the same way Expr<C> already is — one tree type instead of two, with a name-based version (QueryExpr<ColumnRef>, what front ends build) and a positional version (QueryExpr<ColumnId>, what the Binder produces) instead of today's split between a name-based/positional scalar pair sitting inside a single canonical operator tree.

Motivation

Open questions / risks (flagging before work starts, not yet assessed)

Scope

Touches asap-types (the crate every other crate depends on) — expr_ir.rs, query_expr.rs, dag_export.rs — plus every current consumer of L2Expr/L3Expr/Predicate/ProjectItem/SortKey listed above. Expect a multi-PR migration, same caveat as #179.

Related

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions