Class InlineProjectIntoFilter
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.InlineProjectIntoFilter
-
- All Implemented Interfaces:
Rule<FilterNode>
public class InlineProjectIntoFilter extends Object implements Rule<FilterNode>
Replace filter predicate conjuncts with underlying project expressions.Transforms:
- Filter (a AND b > c) - Project a <- d IS NULL b <- b c <- c - source (b, c, d)into:- Project a <- TRUE b <- b c <- c - Filter (d IS NULL AND b > c) - Project b <- b c <- c d <- d - source (b, c, d)In the preceding example, filter predicate conjunct `a` is replaced with project expression `d IS NULL`. Additionally: - an identity assignment `d <- d` is added to the underlying projection in order to expose the symbol `d` used by the rewritten filter predicate, - the inlined assignment `a <- d IS NULL` is removed from the underlying projection. - another projection is added above the rewritten FilterNode, assigning TRUE_LITERAL to the replaced symbol `a`. It is needed to restore the original output of the FilterNode. If the symbol `a` is not referenced in the upstream plan, the projection should be subsequently removed by other rules.Note: project expressions are inlined only in case when the resulting symbols are referenced exactly once in the filter predicate. Otherwise, the resulting plan could be less efficient due to duplicated computation. Also, inlining the expression multiple times is not correct in case of non-deterministic expressions.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result
-
-
Constructor Summary
Constructors Constructor Description InlineProjectIntoFilter(Metadata metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rule.Resultapply(FilterNode node, Captures captures, Rule.Context context)Pattern<FilterNode>getPattern()Returns a pattern to which plan nodes this rule applies.
-
-
-
Constructor Detail
-
InlineProjectIntoFilter
public InlineProjectIntoFilter(Metadata metadata)
-
-
Method Detail
-
getPattern
public Pattern<FilterNode> getPattern()
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<FilterNode>
-
apply
public Rule.Result apply(FilterNode node, Captures captures, Rule.Context context)
- Specified by:
applyin interfaceRule<FilterNode>
-
-