Class DrillPushRowKeyJoinToScanRule
java.lang.Object
org.apache.calcite.plan.RelOptRule
org.apache.drill.exec.planner.logical.DrillPushRowKeyJoinToScanRule
public class DrillPushRowKeyJoinToScanRule
extends org.apache.calcite.plan.RelOptRule
This rule implements the run-time filter pushdown via the rowkey join for queries with row-key filters. Row-key
filters are filters on primary-keys which appears in database groupscans
DbGroupScan
.
Consider the following query:
SELECT L.LINEITEM_ID FROM LINEITEM L WHERE L._ID IN (SELECT O.LID FROM ORDERS O WHERE O.ORDER_DATE > '2019-01-01');
With this rule the logical plan on the left would transform to the logical plan on the right:
Project Project
Join (L._ID = O.LID) RowKeyJoin (L._ID = O.LID)
LineItem L ====>> Lineitem L
Filter (ORDER_DATE > '2019-01-01') Filter (ORDER_DATE > '2019-01-01')
Orders O Orders O
During physical planning, the plan on the left would end up with e.g. HashJoin whereas the transformed plan would
have a RowKeyJoin along with a Restricted GroupScan instead.
Project Project
HashJoin (L._ID = O.LID) RowKeyJoin (L._ID = O.LID)
Scan (LineItem L) RestrictedScan (Lineitem L)
Filter (ORDER_DATE > '2019-01-01') Filter (ORDER_DATE > '2019-01-01')
Scan (Orders O) Scan (Orders O)
The row-key join pushes the `row-keys` for rows satisfying the filter into the Lineitem restricted groupscan. So
we only fetch these rowkeys instead of fetching all rows into the Hash Join.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.calcite.plan.RelOptRule
org.apache.calcite.plan.RelOptRule.ConverterRelOptRuleOperand
-
Field Summary
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doOnMatch
(RowKeyJoinCallContext rkjCallContext) static org.apache.calcite.rel.RelNode
getValidJoinInput
(org.apache.calcite.rel.RelNode rel) boolean
matches
(org.apache.calcite.plan.RelOptRuleCall call) void
onMatch
(org.apache.calcite.plan.RelOptRuleCall call) Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
Field Details
-
match
-
JOIN
-
-
Method Details
-
matches
public boolean matches(org.apache.calcite.plan.RelOptRuleCall call) - Overrides:
matches
in classorg.apache.calcite.plan.RelOptRule
-
onMatch
public void onMatch(org.apache.calcite.plan.RelOptRuleCall call) - Specified by:
onMatch
in classorg.apache.calcite.plan.RelOptRule
-
getValidJoinInput
public static org.apache.calcite.rel.RelNode getValidJoinInput(org.apache.calcite.rel.RelNode rel) -
doOnMatch
-