public class DrillPushRowKeyJoinToScanRule
extends org.apache.calcite.plan.RelOptRule
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.Modifier and Type | Class and Description |
---|---|
static class |
DrillPushRowKeyJoinToScanRule.MatchRelJ |
Modifier and Type | Field and Description |
---|---|
static DrillPushRowKeyJoinToScanRule |
JOIN |
MatchFunction |
match |
Modifier and Type | Method and Description |
---|---|
protected 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) |
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
public final MatchFunction match
public static DrillPushRowKeyJoinToScanRule JOIN
public boolean matches(org.apache.calcite.plan.RelOptRuleCall call)
matches
in class org.apache.calcite.plan.RelOptRule
public void onMatch(org.apache.calcite.plan.RelOptRuleCall call)
onMatch
in class org.apache.calcite.plan.RelOptRule
public static org.apache.calcite.rel.RelNode getValidJoinInput(org.apache.calcite.rel.RelNode rel)
protected void doOnMatch(RowKeyJoinCallContext rkjCallContext)
Copyright © 1970 The Apache Software Foundation. All rights reserved.