Class InlineProjectIntoFilter
java.lang.Object
io.trino.sql.planner.iterative.rule.InlineProjectIntoFilter
- All Implemented Interfaces:
Rule<FilterNode>
Replace filter predicate conjuncts with underlying project expressions.
Transforms:
- Filter (a AND b > c)
- Project
a invalid input: '<'- d IS NULL
b invalid input: '<'- b
c invalid input: '<'- c
- source (b, c, d)
into:
- Project a invalid input: '<'- TRUE b invalid input: '<'- b c invalid input: '<'- c - Filter (d IS NULL AND b > c) - Project b invalid input: '<'- b c invalid input: '<'- c d invalid input: '<'- 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 invalid input: '<'- d` is added to the underlying projection in order to expose the symbol `d` used by the rewritten filter predicate, - the inlined assignment `a invalid input: '<'- 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 -
Method Summary
Modifier and TypeMethodDescriptionapply(FilterNode node, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.
-
Constructor Details
-
InlineProjectIntoFilter
-
-
Method Details
-
getPattern
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<FilterNode>
-
apply
- Specified by:
applyin interfaceRule<FilterNode>
-