Class ExtractDereferencesFromFilterAboveScan
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.ExtractDereferencesFromFilterAboveScan
-
- All Implemented Interfaces:
Rule<FilterNode>
public class ExtractDereferencesFromFilterAboveScan extends Object implements Rule<FilterNode>
Transforms:Filter(f1(A.x.y) = 1 AND f2(B.m) = 2 AND f3(A.x) = 6) Source(A, B, C)to:Project(A, B, C) Filter(f1(D) = 1 AND f2(E) = 2 AND f3(G) = 6) Project(A, B, C, D := A.x.y, E := B.m, G := A.x) Source(A, B, C)This optimizer extracts all dereference expressions from a filter node located above a table scan into a ProjectNode.
Extracting dereferences from a filter (eg. FilterNode(a.x = 5)) can be suboptimal if full columns are being accessed up the plan tree (eg. a), because it can result in replicated shuffling of fields (eg. a.x). So it is safer to pushdown dereferences from Filter only when there's an explicit projection on top of the filter node (Ref PushDereferencesThroughFilter).
In case of a FilterNode on top of TableScanNode, we want to push all dereferences into a new ProjectNode below, so that PushProjectionIntoTableScan optimizer can push those columns in the connector, and provide new column handles for the projected subcolumns. PushPredicateIntoTableScan optimizer can then push predicates on these subcolumns into the connector.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result
-
-
Constructor Summary
Constructors Constructor Description ExtractDereferencesFromFilterAboveScan(TypeAnalyzer typeAnalyzer)
-
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
-
ExtractDereferencesFromFilterAboveScan
public ExtractDereferencesFromFilterAboveScan(TypeAnalyzer typeAnalyzer)
-
-
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>
-
-