Enum Class OptimizationCode
- All Implemented Interfaces:
Serializable,Comparable<OptimizationCode>,Constable
Each constant carries a stable code() string (e.g.
"EXPR-001") used in reports and audit logs, together with a short
description() of what the transformation does.
Codes are grouped by category prefix — one per rule family, in the order the constants are declared below:
EXPR-nnn— arithmetic / expression levelPRED-nnn— predicate simplificationSEL-nnn— selection (σ) rulesPROJ-nnn— projection (π) rulesJOIN-nnn— join / cross-product rulesLATERAL-nnn— lateral (correlated TVF) join decorrelationEQ-nnn— equality propagation across join conditionsLIM-nnn— limit (λ) rulesAGG-nnn— aggregation (γ) rulesDIST-nnn— redundant-δeliminationSORT-nnn— redundant-τeliminationPROD-nnn— Cartesian-product identity eliminationSET-nnn— set-operation identities and common-operator hoistingEMPTY-nnn— empty-relation introduction and propagationNEST-nnn— nest/unnest (NF²) round-trip rulesCLOSURE-nnn— endpoint bounds folded intoCLOSURETRACE-nnn— endpoint bounds folded intoTRACEPATH-nnn— endpoint bounds folded intoPATHFIX-nnn— magic sets into aFIXrecursionGEN-nnn— production bounds folded into a generatorWINDOW-nnn— partition pruning intoWINDOWTOPK-nnn— partition pruning intoTOPOPTIMIZE-nnn— group pruning into theOPTIMIZEsolverSESSION-nnn— partition pruning intoSESSIONIZEDOWNSAMPLE-nnn— group pruning intoDOWNSAMPLEINLINE-nnn— view-body inliningRENAME-nnn— rename collapsing / elimination
OptimizationCodeTest asserts that this list and the declared constants
name the same set of categories, so adding a category without documenting it fails
the build.
The category() convenience method returns the prefix string
(e.g. "EXPR") derived from code().
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCollapse a redundant outer aggregation directly above another aggregation: when the outerAggregationNodehas no aggregate functions and its grouping keys (as a set) are exactly the inner aggregation's output columns, the inner already emits one row per grouping-key combination, so re-grouping by all of its columns is a no-op and the outer aggregation is removed (γ cols [] (γ keys, aggs (R))→γ keys, aggs (R)).Fold a constant endpoint equality above aCLOSURE/RCLOSUREinto the operator as a source/target bound, turning all-pairs reachability into single-source / single-target / single-pair traversal — the canonical magic-sets / sideways-information-passing rewrite.Remove aδ(DISTINCT) whose input is already provably duplicate-free, so the deduplication is redundant (δ(R)→RwhenRis whole-row distinct or has a candidate key — e.g.Remove aδ(DISTINCT) below an aggregation that ignores multiplicity, so the deduplication is work its consumer does not need (γ keys, aggs (δ R)→γ keys, aggs (R)when the γ has no aggregates, or onlyMIN/MAXover deterministic arguments).Prune aDownsampleNodeto the group(s) a selection fixes: an equalitygroupingKey = constanton aPERcolumn above the operator is pushed below it, so only the matching group's rows are bucketed and consolidated (σ k = c (DOWNSAMPLE … PER k (R))→DOWNSAMPLE … PER k (σ k = c (R))).Replace a selection whose predicate is constant-false with the empty relation carrying that selection's heading (σ false (R)→∅).Replace an operator with the empty relation because an input that forces emptiness is empty (∅ ⋈ X→∅).Drop an empty right branch of a bag union (X ⊎ ∅→X).Propagate a literal binding across an equi-join's equality classes, so a filter written against one side also constrains the other (A.x = B.x ∧ A.x = 5 ⊨ B.x = 5).Evaluate a binary arithmetic expression whose both operands are numeric literals at planning time (e.g.Evaluate a string concatenation whose both operands are string literals at planning time (e.g.Remove addition or subtraction of zero (x + 0→x,x − 0→x,0 + x→x).Remove multiplication by one or division by one (x * 1→x,1 * x→x,x / 1→x).Replace multiplication by zero with zero (x * 0→0,0 * x→0).Remove double unary negation (−(−x)→x).Reassociate constants in a chain of the same commutative+associative operator so they can be folded together ((x + k1) + k2→x + (k1+k2)).Remove a redundant outer call to an idempotent single-argument built-in function (f(f(x))→f(x)).Push a selection over frozen columns into aFIXleast-fixpoint — the general magic-sets / sideways-information-passing rewrite over arbitrary monotone, linear recursion — the umbrella case of whichCLOSURE-001/TRACE-001are fixed-shape instances.Fold a top-level upper-bound equality/inequality above a monotone unbounded generator (Naturals/Primes) into the producer as a generation stop, so the otherwise non-terminating scan is finite.Replace a reference to a named view (QueryRelationSymbol) with the view's own body, so that later rules (e.g.Convert aSelectionNodeapplied to aProductNodeinto aThetaJoinNode, allowing the executor to filter during the join rather than afterwards.Push a selection whose predicate references only one side of a join down into that join input.Demote an outer join to a less outer one when a predicate above it rejects NULLs on a column from the padded side, making the rows that join produced by padding unreachable (σ p (A ⟕ B)→σ p (A ⨝θ B)whenprejects NULLs on a column ofB).Turn an uncorrelatedLATERALtable-valued-function join into a plain Cartesian product against a single TVF call (L LATERAL f(args)→L × f(args)) when no argument references a column of the left input.Push aLimitNodebelow an interveningProjectionNode, since projection is row-count neutral.Push aLimitNodebelow aRenameNode: a rename touches names, never rows, so it is row-count and order neutral (λ(off, n)(ρ … (R))→ρ … (λ(off, n)(R))).Fuse a limit over a sort into aTopKNode— the classic top-N rewrite (λ(off, n)(τ k (R))→TOP n OFFSET off ORDER BY k (R), with no grouping keys, i.e.Replicate a limit into both branches of aUnionAllNode, so neither branch produces more rows than the whole union can possibly use (λ n (A ⊎ B)→λ n ((λ n A) ⊎ (λ n B))).Collapse a nest immediately undone by an unnest — theμ ∘ COLLECT = idround-trip law (after Hölsch, Grossniklaus & Scholl, SIGMOD 2016).Push a selection below anμ(UNNEST) when its predicate references neither the unnested column nor theWITH ORDINALITYcolumn, so the filter runs before the row-multiplying explode (σ p (μ c (R))→μ c (σ p (R))).Push a column-pruning projection below anμ(UNNEST) so fewer columns flow through the row-multiplying explode (π cols (μ c (R))→μ c (π cols (R))); fires only when every projected attribute is a bare column, the unnested column is projected unaliased, and there is noWITH ORDINALITYcolumn.Prune anOptimizeNodeto the group(s) a selection fixes: an equalitygroupingKey = constanton aPERkey above the operator is pushed below it, so the solver runs its MIP/LP for only the matching group instead of every group (σ k = c (OPTIMIZE … PER k (R))→OPTIMIZE … PER k (σ k = c (R))).Fold a constant endpoint equality above aPATHbounded-traversal operator into the operator as a source/target bound, turning an all-pairs breadth-first search into a single-source / single-target / single-pair one.Simplify AND or OR expressions that have a constant-true or constant-false branch.Remove double logical negation (¬¬p→p).Swap the operands of a comparison predicate so the literal is always on the right, mirroring the operator as needed (5 > age→age < 5).Collapse a conjunction whose bounds on one column cannot all hold to the constant-false predicate (x > 5 ∧ x < 3,x = 5 ∧ x = 6).Drop a bound another conjunct on the same column already implies (x > 5 ∧ x > 3→x > 5).Remove a conjunct that repeats one already present (p ∧ p→p), compared structurally.Drop a Cartesian product against the one-tuple truth relationUNIT(DEE), which is the identity of×(R × UNIT→R,UNIT × R→R).Remove a projection that outputs exactly the same schema as its input (a no-op pass-through).Merge two stacked projections into one (π a (π a,b R)→π a R).Push a projection below an intervening selection so fewer columns are carried through the selection evaluation.Prune the columns a query never reads, by a top-down "required columns" walk: each node is told which of its output columns its parent needs and derives what it therefore needs from each child, so a base relation is wrapped in a narrowingπwhenever the query reads strictly fewer columns than the table has (γ region, SUM(amount) (Sales)→γ region, SUM(amount) (π region, amount (Sales))), and an intermediateπis narrowed to the columns actually read above it.Collapse a relation-onlyρinto theρdirectly beneath it (ρ V (ρ W [spec] (R))→ρ V [spec] (R)).Remove a relation-onlyρwhose alias nothing references (ρ V (X)→X) — the wrapperViewInlinerputs around every inlined view body, which otherwise survives into the final plan and sits between operators that later passes need to see adjacent.Drop a column rename that renames a column to the name it already has (ρ id→id, a→q (A)→ρ a→q (A)).Compose a pair-formρwith the pair-formρbeneath it (ρ b→c (ρ a→b (R))→ρ a→c (R)).Split a conjunctive selection into two stacked selections (σ A∧B R→σ A (σ B R)), enabling independent pushdown of each part.Merge two adjacent selections back into one conjunctive predicate (σ A (σ B R)→σ A∧B R), reducing operator count.Push a selection below an intervening projection when all referenced attributes are present in the projection's input schema.Push a selection below a rename, rewriting attribute references to match the pre-rename column names.Push a selection into the appropriate input of a join when the predicate references only one side's columns.Replicate a selection into both branches of aUnionAllNodeso each branch filters rows early.Demote aHAVING-position selection to aWHERE-position one: a conjunct that references only bare-column grouping keys of theAggregationNodebelow it is evaluated before the blocking γ rather than after (σ p (γ keys, aggs (R))→γ keys, aggs (σ p (R))whenattrs(p) ⊆ keys).Push a selection below aδ(DISTINCT) or aτ(SORT).Distribute a selection over a set operation so each branch filters early: replicated into both branches of∪,∩,∆and−.Merge a set operation over two selections of the same input into one selection (σi(A) ∪ σq(A)→δ σ(i ∨ q)(A),σi(A) ∩ σq(A)→δ σ(i ∧ q)(A)), the inverse ofSEL_009and so registered in a later phase.Prune aSessionizeNodeto the partition(s) a selection fixes: an equalitypartitionKey = constanton aPERcolumn above the operator is pushed below it, so only the matching partition is buffered, sorted and walked for session boundaries (σ k = c (SESSIONIZE … PER k (R))→SESSIONIZE … PER k (σ k = c (R))).Remove a set operation whose two sides are the same expression (R ∪ R→δ R,R ∩ R→δ R,R − R→∅,R ∆ R→∅).Remove a set operation between a selection and its own input (σk(R) ∪ R→δ R,σk(R) ∩ R→δ σk(R),σk(R) − R→∅), in either operand order for the commutative arms.Hoist aρboth branches of a set operation apply identically (ρ spec (R) ∪ ρ spec (Q)→ρ spec (R ∪ Q); likewise∩,−,∆,⊎).Hoist aπboth branches of a∪apply identically (π cols (A) ∪ π cols (B)→δ π cols (A ∪ B)).Hoist a×both branches of a∪apply to the same operand on the same side (A × B ∪ A × C→δ (A × (B ∪ C)),A × C ∪ B × C→δ ((A ∪ B) × C)).Remove aτ(SORT) whose input already delivers an order that satisfies it, so the sort is redundant (τ keys (R)→RwhenR's delivered order haskeysas a prefix — e.g.Prune aTopKNodeto the partition(s) a selection fixes: an equalitypartitionKey = constanton aPERgrouping column above the top-k is pushed below it, so top-k is computed for only the matching group instead of every group (σ k = c (TOP n … PER k (R))→TOP n … PER k (σ k = c (R))).Fold a constant endpoint equality above aTRACEoptimal-path operator into the operator as a source/target bound, turning all-pairs path search into single-source / single-target / single-pair search.Prune a partitionedWindowNodeto the partition(s) a selection fixes: an equalitypartitionKey = constanton aPARTITION BYcolumn above the window is pushed below it, so the per-partition window computation runs over only the matching partition and the other partitions are never computed (σ k = c (WINDOW … PARTITION BY k …)→WINDOW … PARTITION BY k … (σ k = c (R))). -
Method Summary
Modifier and TypeMethodDescriptioncategory()Returns the category prefix of this code (the part before the first'-'), e.g.code()Returns the stable string code used in reports and audit logs, e.g.Returns a short human-readable description of what this transformation does.toString()Returns a combined"code — description"string suitable for display in reports.static OptimizationCodeReturns the enum constant of this class with the specified name.static OptimizationCode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
EXPR_001
Evaluate a binary arithmetic expression whose both operands are numeric literals at planning time (e.g.2 * 3→6). -
EXPR_002
Evaluate a string concatenation whose both operands are string literals at planning time (e.g."a" + "b"→"ab"). -
EXPR_003
Remove addition or subtraction of zero (x + 0→x,x − 0→x,0 + x→x). -
EXPR_004
Remove multiplication by one or division by one (x * 1→x,1 * x→x,x / 1→x). -
EXPR_005
Replace multiplication by zero with zero (x * 0→0,0 * x→0). -
EXPR_006
Remove double unary negation (−(−x)→x). -
EXPR_007
Reassociate constants in a chain of the same commutative+associative operator so they can be folded together ((x + k1) + k2→x + (k1+k2)). -
EXPR_008
Remove a redundant outer call to an idempotent single-argument built-in function (f(f(x))→f(x)). -
PRED_001
Simplify AND or OR expressions that have a constant-true or constant-false branch. -
PRED_002
Remove double logical negation (¬¬p→p). -
PRED_003
Swap the operands of a comparison predicate so the literal is always on the right, mirroring the operator as needed (5 > age→age < 5). -
PRED_004
Collapse a conjunction whose bounds on one column cannot all hold to the constant-false predicate (x > 5 ∧ x < 3,x = 5 ∧ x = 6). -
PRED_005
Drop a bound another conjunct on the same column already implies (x > 5 ∧ x > 3→x > 5). -
PRED_006
Remove a conjunct that repeats one already present (p ∧ p→p), compared structurally. -
SEL_001
Split a conjunctive selection into two stacked selections (σ A∧B R→σ A (σ B R)), enabling independent pushdown of each part. -
SEL_002
Merge two adjacent selections back into one conjunctive predicate (σ A (σ B R)→σ A∧B R), reducing operator count. -
SEL_003
Push a selection below an intervening projection when all referenced attributes are present in the projection's input schema. -
SEL_004
Push a selection below a rename, rewriting attribute references to match the pre-rename column names. -
SEL_005
Push a selection into the appropriate input of a join when the predicate references only one side's columns. -
SEL_006
Replicate a selection into both branches of aUnionAllNodeso each branch filters rows early. -
SEL_007
Demote aHAVING-position selection to aWHERE-position one: a conjunct that references only bare-column grouping keys of theAggregationNodebelow it is evaluated before the blocking γ rather than after (σ p (γ keys, aggs (R))→γ keys, aggs (σ p (R))whenattrs(p) ⊆ keys). A conjunct touching an aggregate output stays above as a residualσ. -
SEL_008
Push a selection below aδ(DISTINCT) or aτ(SORT). Both are row-preserving and column-preserving with respect to a filter, so filtering first is free and means fewer rows reach a blocking operator (σ p (δ R)→δ (σ p R),σ p (τ k R)→τ k (σ p R)). -
SEL_009
Distribute a selection over a set operation so each branch filters early: replicated into both branches of∪,∩,∆and−. The subtrahend is included because the same predicate is applied to the minuend: a row the filtered subtrahend no longer removes is a row the filtered minuend no longer offers, soσp(A − B) = σpA − σpBexactly.⊎isSEL_006;⊔(outer union) is excluded because its branches have different schemas, so a predicate valid against one may reference a column absent from the other. -
SEL_010
Merge a set operation over two selections of the same input into one selection (σi(A) ∪ σq(A)→δ σ(i ∨ q)(A),σi(A) ∩ σq(A)→δ σ(i ∧ q)(A)), the inverse ofSEL_009and so registered in a later phase. It deletes a blocking operator outright and leaves one filtered read where there were two, which is also what lets the backend fold the whole thing into a singleWHERE. Theδis dropped when the input is provably duplicate-free. The−arm isi ∧ (¬q ∨ q IS UNKNOWN)rather than thei ∧ ¬qit looks like: the subtrahend also fails to hold a row whoseqis UNKNOWN, so the difference keeps one where a bare¬qdrops it — seeSelectionComplement. -
PROJ_001
Remove a projection that outputs exactly the same schema as its input (a no-op pass-through). -
PROJ_002
Merge two stacked projections into one (π a (π a,b R)→π a R). -
PROJ_003
Push a projection below an intervening selection so fewer columns are carried through the selection evaluation. -
PROJ_004
Prune the columns a query never reads, by a top-down "required columns" walk: each node is told which of its output columns its parent needs and derives what it therefore needs from each child, so a base relation is wrapped in a narrowingπwhenever the query reads strictly fewer columns than the table has (γ region, SUM(amount) (Sales)→γ region, SUM(amount) (π region, amount (Sales))), and an intermediateπis narrowed to the columns actually read above it. Width multiplies through everything downstream — theSELECTlist a pushdown renderer emits, a hash join's build side, and every materializing operator (ColumnPruningPass). -
JOIN_001
Convert aSelectionNodeapplied to aProductNodeinto aThetaJoinNode, allowing the executor to filter during the join rather than afterwards. -
JOIN_002
Push a selection whose predicate references only one side of a join down into that join input. -
JOIN_004
Demote an outer join to a less outer one when a predicate above it rejects NULLs on a column from the padded side, making the rows that join produced by padding unreachable (σ p (A ⟕ B)→σ p (A ⨝θ B)whenprejects NULLs on a column ofB). A⟗demotes one half at a time, to⟕/⟖and then to⨝θ. The demotion is a gate in front of several optimizations an outer join cannot have: σ pushdown into both sides, sort-merge planning,JOIN … ONpushdown, andEQ-001.c IS NULLis deliberately not null-rejecting — that is the anti-join idiom (OuterJoinDemotionPass). -
LATERAL_001
Turn an uncorrelatedLATERALtable-valued-function join into a plain Cartesian product against a single TVF call (L LATERAL f(args)→L × f(args)) when no argument references a column of the left input. The lateral operator re-plans and re-executes the function body once per left row; with constant arguments every one of those invocations produces the same relation, so a single call is equivalent — the schema isleft ++ bodyeither way, and×pairs the two sides in the same order the lateral concatenates them.Beyond the per-row work it removes, the rewrite is what makes the operator visible:
RelNode.children()reports only the left input, so the TVF body is outside structural traversal and no other rule can see through it. As a×it can become a theta join (JOIN-001), take a pushed selection, and be reordered (LateralDecorrelationPass). -
EQ_001
Propagate a literal binding across an equi-join's equality classes, so a filter written against one side also constrains the other (A.x = B.x ∧ A.x = 5 ⊨ B.x = 5). The derived predicate is placed as aσdirectly on the side whose schema owns the column, so with capability-based pushdown both backends filter independently instead of one shipping its whole table for the engine to discard. Inner (ThetaJoinNode) joins only — an outer join's condition does not hold of its padded rows (TransitiveEqualityPass). -
LIM_001
Push aLimitNodebelow an interveningProjectionNode, since projection is row-count neutral. -
LIM_002
Push aLimitNodebelow aRenameNode: a rename touches names, never rows, so it is row-count and order neutral (λ(off, n)(ρ … (R))→ρ … (λ(off, n)(R))). -
LIM_003
Fuse a limit over a sort into aTopKNode— the classic top-N rewrite (λ(off, n)(τ k (R))→TOP n OFFSET off ORDER BY k (R), with no grouping keys, i.e. one global group). The pair materializes and sorts the whole input to then discard all butnrows;TOPkeeps a bounded heap instead. The λ's offset carries across unchanged, sinceTopKNodeskips before it takes. -
LIM_004
Replicate a limit into both branches of aUnionAllNode, so neither branch produces more rows than the whole union can possibly use (λ n (A ⊎ B)→λ n ((λ n A) ⊎ (λ n B))). The outer λ must stay: each branch may supply fewer thannrows. With an offset the branch bound isoffset + count— the outer λ still has to skip. -
AGG_001
Collapse a redundant outer aggregation directly above another aggregation: when the outerAggregationNodehas no aggregate functions and its grouping keys (as a set) are exactly the inner aggregation's output columns, the inner already emits one row per grouping-key combination, so re-grouping by all of its columns is a no-op and the outer aggregation is removed (γ cols [] (γ keys, aggs (R))→γ keys, aggs (R)). -
DIST_001
Remove aδ(DISTINCT) whose input is already provably duplicate-free, so the deduplication is redundant (δ(R)→RwhenRis whole-row distinct or has a candidate key — e.g.δoverγ, a set operation, transitive closure, or anotherδ). Distinctness is derived bottom-up byPropertyDeriver. -
DIST_002
Remove aδ(DISTINCT) below an aggregation that ignores multiplicity, so the deduplication is work its consumer does not need (γ keys, aggs (δ R)→γ keys, aggs (R)when the γ has no aggregates, or onlyMIN/MAXover deterministic arguments). WhereDIST_001looks down from theδat an input that is already a set, this looks up at a consumer that would collapse the duplicates anyway.SUM/COUNT/AVG/COLLECTread multiplicity and block it, as doARGMAX/ARGMIN. The rule looks through an interveningσ/π/ρ/τ— each emits at most one row per input row — but not aλ/sample/TOP, whose output depends on how many rows arrive. -
SORT_001
Remove aτ(SORT) whose input already delivers an order that satisfies it, so the sort is redundant (τ keys (R)→RwhenR's delivered order haskeysas a prefix — e.g.τover a compatibleτ, or overσ/λabove one). The delivered order is derived byOrderDeriver. -
PROD_001
Drop a Cartesian product against the one-tuple truth relationUNIT(DEE), which is the identity of×(R × UNIT→R,UNIT × R→R).UNIThas the empty heading and exactly one row, so the product reproducesR's rows and its column order exactly — unlike swapping a product's operands, which permutes the ordered output schema. The zero-tupleEMPTY(DUM) has no matching rule:R × EMPTYis empty but keepsR's heading, so it cannot be rewritten to the zero-columnEMPTY. -
SET_001
Remove a set operation whose two sides are the same expression (R ∪ R→δ R,R ∩ R→δ R,R − R→∅,R ∆ R→∅). Structural equality isAstEquivalence, so the two sides match however far apart they were written. Theδis not decoration:∪and∩declareSET, and handing back a bareRwould make a distinctness claim the input need not honour. It is dropped whenRis provably duplicate-free. Gated onRbeing reproducible —X ∆ Xover an unseededSAMPLEis a query about two draws. -
SET_002
Remove a set operation between a selection and its own input (σk(R) ∪ R→δ R,σk(R) ∩ R→δ σk(R),σk(R) − R→∅), in either operand order for the commutative arms. Sameδrule and same reproducibility gate asSET_001. The other direction is the selection's complement —R − σk(R)→δ σ (¬k ∨ k IS UNKNOWN) (R), andσk(R) ∆ Ris that same difference written another way — where a plainσ¬k(R)would drop every row whosekcould not be decided. -
SET_003
Hoist aρboth branches of a set operation apply identically (ρ spec (R) ∪ ρ spec (Q)→ρ spec (R ∪ Q); likewise∩,−,∆,⊎). Unlike the two arms below this one needs no distinctness argument: a rename changes no value and drops no column, and the whole-row set operations match positionally and name-blind, so the rows being de-duplicated are the same before and after. -
SET_004
Hoist aπboth branches of a∪apply identically (π cols (A) ∪ π cols (B)→δ π cols (A ∪ B)). Theδis what keeps it sound:πdoes not de-duplicate, so hoisting moves the∪'s de-duplication from after the narrowing to before it. Fires only when both inputs carry an inferred heading and the two headings agree name for name in order, since the∪pairs their columns by position while theπnames them. -
SET_005
Hoist a×both branches of a∪apply to the same operand on the same side (A × B ∪ A × C→δ (A × (B ∪ C)),A × C ∪ B × C→δ ((A ∪ B) × C)).δforSET_004's reason. The same side condition is not a simplification:A × B ∪ C × Ahas the common operand at opposite ends, so factoring it would permute the ordered heading the positional consumers read — which is whatJOIN-003was removed for. -
EMPTY_001
Replace a selection whose predicate is constant-false with the empty relation carrying that selection's heading (σ false (R)→∅). -
EMPTY_002
Replace an operator with the empty relation because an input that forces emptiness is empty (∅ ⋈ X→∅). -
EMPTY_003
Drop an empty right branch of a bag union (X ⊎ ∅→X). -
NEST_001
Collapse a nest immediately undone by an unnest — theμ ∘ COLLECT = idround-trip law (after Hölsch, Grossniklaus & Scholl, SIGMOD 2016). When aμunnests exactly the array column produced by a singleCOLLECTaggregate of theAggregationNodedirectly beneath it, the group-then-explode reproduces the pre-nest rows, so the pair is rewritten to a plain projection (μ g (γ keys, COLLECT(x)→g (R))→π keys, (x → g) (R)), removing a blockingγand theμ. -
NEST_002
Push a selection below anμ(UNNEST) when its predicate references neither the unnested column nor theWITH ORDINALITYcolumn, so the filter runs before the row-multiplying explode (σ p (μ c (R))→μ c (σ p (R))). -
NEST_003
Push a column-pruning projection below anμ(UNNEST) so fewer columns flow through the row-multiplying explode (π cols (μ c (R))→μ c (π cols (R))); fires only when every projected attribute is a bare column, the unnested column is projected unaliased, and there is noWITH ORDINALITYcolumn. -
CLOSURE_001
Fold a constant endpoint equality above aCLOSURE/RCLOSUREinto the operator as a source/target bound, turning all-pairs reachability into single-source / single-target / single-pair traversal — the canonical magic-sets / sideways-information-passing rewrite. Fires on a top-level conjoined equality on thefrom/tocolumn against a literal in the selection chain directly above the closure; any non-pushable conjunct remains as aσabove, so the rewrite is a no-op when nothing is pushable.σ from = c (CLOSURE from, to (E))→CLOSURE from, to ⟨from=c⟩ (E). -
TRACE_001
Fold a constant endpoint equality above aTRACEoptimal-path operator into the operator as a source/target bound, turning all-pairs path search into single-source / single-target / single-pair search. Fires on a top-level conjoined equality on thefrom/tocolumn against a literal in the selection chain directly above the trace; any non-pushable conjunct remains as aσabove (no-op when nothing is pushable).σ from = c (TRACE from, to VIA w … (E))→TRACE from, to VIA w … ⟨from=c⟩ (E). -
PATH_001
Fold a constant endpoint equality above aPATHbounded-traversal operator into the operator as a source/target bound, turning an all-pairs breadth-first search into a single-source / single-target / single-pair one. Thedepthcolumn is unaffected: the shortest path from a seed does not depend on which other nodes were searched from, so the bounded result is a slice of the unbounded one.σ from = c (PATH from, to HOPS m TO n AS d (E))→PATH from, to HOPS m TO n AS d ⟨from=c⟩ (E). -
FIX_001
Push a selection over frozen columns into aFIXleast-fixpoint — the general magic-sets / sideways-information-passing rewrite over arbitrary monotone, linear recursion — the umbrella case of whichCLOSURE-001/TRACE-001are fixed-shape instances. When every attribute a top-level conjunct references is frozen — carried unchanged by the step from the recursive reference to its output — the selection distributes over the fixpoint:σ p (FIX name (base, step))≡FIX name (σ p (base), step[name ↦ σ p (name)]), so the recursion is seeded and restricted bypand the full fixpoint is avoided. Sound by the step's validator-enforced linearity + monotonicity. Non-frozen conjuncts remain as a residualσabove (no-op when nothing is pushable).σ assembly = "Bike" (FIX BOM (Contains, π assembly, … (BOM ⋈ …)))→FIX BOM (σ assembly = "Bike" (Contains), π … (σ assembly = "Bike" (BOM) ⋈ …)). -
GEN_001
Fold a top-level upper-bound equality/inequality above a monotone unbounded generator (Naturals/Primes) into the producer as a generation stop, so the otherwise non-terminating scan is finite. Fires onσ n < k/n <= k/n = kdirectly above the generator's ascending value column; the σ is kept above as a residual filter (correctness by construction), and the leaf becomes boundedness-BOUNDED so a downstream blocking operator over it is legal.σ n < 100 (Naturals)→σ n < 100 (Naturals ⟨produce while n < 100⟩). -
WINDOW_001
Prune a partitionedWindowNodeto the partition(s) a selection fixes: an equalitypartitionKey = constanton aPARTITION BYcolumn above the window is pushed below it, so the per-partition window computation runs over only the matching partition and the other partitions are never computed (σ k = c (WINDOW … PARTITION BY k …)→WINDOW … PARTITION BY k … (σ k = c (R))). Safe because the window frame never crosses a partition boundary, so the per-partition result is identical. Predicates on non-partition or computed columns stay as a residualσabove the window. -
TOPK_001
Prune aTopKNodeto the partition(s) a selection fixes: an equalitypartitionKey = constanton aPERgrouping column above the top-k is pushed below it, so top-k is computed for only the matching group instead of every group (σ k = c (TOP n … PER k (R))→TOP n … PER k (σ k = c (R))). Safe because top-k is computed independently per group; predicates on non-partition columns stay as a residualσabove. -
OPTIMIZE_001
Prune anOptimizeNodeto the group(s) a selection fixes: an equalitygroupingKey = constanton aPERkey above the operator is pushed below it, so the solver runs its MIP/LP for only the matching group instead of every group (σ k = c (OPTIMIZE … PER k (R))→OPTIMIZE … PER k (σ k = c (R))). Safe becauseOPTIMIZEsolves each group's problem independently; a predicate on a non-grouping column changes the optimum under emit-the-optimum semantics and stays as a residualσabove . -
SESSION_001
Prune aSessionizeNodeto the partition(s) a selection fixes: an equalitypartitionKey = constanton aPERcolumn above the operator is pushed below it, so only the matching partition is buffered, sorted and walked for session boundaries (σ k = c (SESSIONIZE … PER k (R))→SESSIONIZE … PER k (σ k = c (R))). Safe because a session boundary never spans aPERkey (SelectionIntoTimeSeriesPass). -
DOWNSAMPLE_001
Prune aDownsampleNodeto the group(s) a selection fixes: an equalitygroupingKey = constanton aPERcolumn above the operator is pushed below it, so only the matching group's rows are bucketed and consolidated (σ k = c (DOWNSAMPLE … PER k (R))→DOWNSAMPLE … PER k (σ k = c (R))). Does not fire when the operator carriesFOR n ROWS: that keeps thenmost recent buckets across all groups, so pushing a group filter below it changes which buckets survive (SelectionIntoTimeSeriesPass). -
INLINE_001
Replace a reference to a named view (QueryRelationSymbol) with the view's own body, so that later rules (e.g. selection/projection pushdown) can optimise across the former view boundary. -
RENAME_001
Collapse a relation-onlyρinto theρdirectly beneath it (ρ V (ρ W [spec] (R))→ρ V [spec] (R)). Unconditional: the outer rename re-anchors every column's provenance toV, soWis not a resolvable qualifier at the outer node's output either way (RenameEliminationPass). -
RENAME_002
Remove a relation-onlyρwhose alias nothing references (ρ V (X)→X) — the wrapperViewInlinerputs around every inlined view body, which otherwise survives into the final plan and sits between operators that later passes need to see adjacent. Fires only when a whole-tree sweep finds neitherVnor any relation nameXwould re-expose used as a qualifier, since a relation-qualified reference resolves by column provenance (RenameEliminationPass). -
RENAME_003
Drop a column rename that renames a column to the name it already has (ρ id→id, a→q (A)→ρ a→q (A)). Dropping the pairs is unconditional; dropping the node is not, since it may still carry a relation name something references — so the node is reduced to its relation-only form andRENAME_002decides whether it lives (RenameEliminationPass). -
RENAME_004
Compose a pair-formρwith the pair-formρbeneath it (ρ b→c (ρ a→b (R))→ρ a→c (R)). Each inner pair's target is looked up among the outer's sources and the chain is collapsed; an outer pair that renames a pass-through column is carried over unchanged. Declines when the two rename the same source column, where the outer pair names a column the inner has already consumed. A rename cycle needs no arm of its own — it composes to an identity pair, whichRENAME_003then drops.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
code
Returns the stable string code used in reports and audit logs, e.g."EXPR-001".- Returns:
- the code string; never null or blank
-
description
Returns a short human-readable description of what this transformation does.- Returns:
- the description; never null or blank
-
category
- Returns:
- the category string; never null or blank
-
toString
Returns a combined"code — description"string suitable for display in reports.- Overrides:
toStringin classEnum<OptimizationCode>- Returns:
- formatted string; never null
-