Expand description
Transformations of SQL IR, before decorrelation.
StaticsΒ§
- NO_
PARAMS π - An empty parameter type map.
FunctionsΒ§
- column_
type π - from_
less_ πexistence_ predicate - If
subis a FROM-less subquery (seesimplify_from_less_existence_subqueries) whose existence check is correlated on the outer row, returns the predicatep1 AND p2 AND ...expressed in the outer rowβs frame. ReturnsNoneotherwise. - fuse_
window_ functions - Aims and scope
- relation_
contains_ πsubquery - Returns whether
exprcontains any subquery (HirScalarExpr::ExistsorHirScalarExpr::Select). Both the relation tree and the per-node scalars are traversed iteratively, so this is stack-safe on deeply nested inputs: a long JOIN/CTE chain grows the relation tree, and a flatCASEwith many arms lowers to a deep right-nestedIfchain in a single scalar.visit_preonHirScalarExprstops atExists/Select(they are scalar leaves), so the scan never descends into subquery bodies. The relation walk already yields those bodies as its own children. - resolve_
local_ πcolumns - Returns
exprwith every reference to the current scope (aColumnRefwithlevel == 0) replaced by its value fromenv. ReturnsNoneifexprcannot be soundly lifted into the outer scope, or references a column absent fromenv. - simplify_
from_ less_ existence_ subqueries - Collapses
EXISTSover a FROM-less subquery into an equivalent scalar predicate on the outer row, so that decorrelation produces a plainFilterrather than a semijoin (forEXISTS) or an antijoin (forNOT EXISTS). - split_
subquery_ predicates - Rewrites predicates that contain subqueries so that the subqueries appear in their own later predicate when possible.
- try_
simplify_ quantified_ comparisons - Rewrites quantified comparisons into simpler EXISTS operators.