Package org.apache.calcite.rel.rules
Class SingleValuesOptimizationRules.PruneSingleValueRule
java.lang.Object
org.apache.calcite.plan.RelOptRule
org.apache.calcite.plan.RelRule<SingleValuesOptimizationRules.PruneSingleValueRule.Config>
org.apache.calcite.rel.rules.SingleValuesOptimizationRules.PruneSingleValueRule
- All Implemented Interfaces:
SubstitutionRule
,TransformationRule
- Enclosing class:
SingleValuesOptimizationRules
protected abstract static class SingleValuesOptimizationRules.PruneSingleValueRule
extends RelRule<SingleValuesOptimizationRules.PruneSingleValueRule.Config>
implements SubstitutionRule
Abstract class for all the SingleValuesOptimizationRules. All the specific
SingleValuesOptimizationRules call the onMatch function to replace a Join
with equivalent tree when eligible.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Rule configuration.Nested classes/interfaces inherited from class org.apache.calcite.plan.RelRule
RelRule.Done, RelRule.MatchHandler<R extends RelOptRule>, RelRule.OperandBuilder, RelRule.OperandDetailBuilder<R extends RelNode>, RelRule.OperandTransform
Nested classes/interfaces inherited from class org.apache.calcite.plan.RelOptRule
RelOptRule.ConverterRelOptRuleOperand
-
Field Summary
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
Constructor Summary
ModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether the planner should automatically prune old node when there is at least 1 equivalent rel generated by the rule.getRexTransformer
(RexBuilder rexBuilder, JoinRelType joinRelType) protected void
onMatch
(RelOptRuleCall call, Values values, @Nullable Project project, Join join, RelNode other, boolean isOnLefSide) onMatch function contains common optimization logic for all the SingleValueOptimization rules.Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, onMatch, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
Constructor Details
-
PruneSingleValueRule
-
-
Method Details
-
getRexTransformer
protected BiFunction<RexNode,List<RexNode>, getRexTransformerList<RexNode>> (RexBuilder rexBuilder, JoinRelType joinRelType) -
onMatch
protected void onMatch(RelOptRuleCall call, Values values, @Nullable Project project, Join join, RelNode other, boolean isOnLefSide) onMatch function contains common optimization logic for all the SingleValueOptimization rules. It simplifies the rel node tree by removing a Join node and creating a required filter as applicable. In case of the LEFT/RIGHT joins, a case expression which produce NULL values for non-matching rows will be created as part of a Project node. The transformation can be illustrated by following e.g. TableScan(Emp) join (cond: Emp.empno = v.no) with Values(1010 as no) → Filter(Emp.empno = 1010) on TableScan(Emp)- Parameters:
call
- A RelOptRuleCall objectvalues
- A constant relation node which produces a single row.project
- A project node which has dynamic constants (can be null).join
- A join node which will get removed.other
- A node on the other side of the join (apart from Values)isOnLefSide
- Whether a Values node is on the Left side or the right side of the Join.
-
autoPruneOld
public boolean autoPruneOld()Description copied from interface:SubstitutionRule
Whether the planner should automatically prune old node when there is at least 1 equivalent rel generated by the rule.Default is false, the user needs to prune the old node manually in the rule.
- Specified by:
autoPruneOld
in interfaceSubstitutionRule
-