Class ExtractDereferencesFromFilterAboveScan
- All Implemented Interfaces:
Rule<FilterNode>
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 -
Method Summary
Modifier and TypeMethodDescriptionapply(FilterNode node, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.
-
Constructor Details
-
ExtractDereferencesFromFilterAboveScan
-
-
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>
-