Package org.apache.calcite.rel.rules
Class JoinProjectTransposeRule
- java.lang.Object
-
- org.apache.calcite.plan.RelOptRule
-
- org.apache.calcite.rel.rules.JoinProjectTransposeRule
-
- Direct Known Subclasses:
MultiJoinProjectTransposeRule
public class JoinProjectTransposeRule extends RelOptRule
Planner rule that matches aJoin
one of whose inputs is aLogicalProject
, and pulls the project up.Projections are pulled up if the
LogicalProject
doesn't originate from a null generating input in an outer join.
-
-
Field Summary
Fields Modifier and Type Field Description static JoinProjectTransposeRule
BOTH_PROJECT
static JoinProjectTransposeRule
BOTH_PROJECT_INCLUDE_OUTER
private boolean
includeOuter
static JoinProjectTransposeRule
LEFT_PROJECT
static JoinProjectTransposeRule
LEFT_PROJECT_INCLUDE_OUTER
static JoinProjectTransposeRule
RIGHT_PROJECT
static JoinProjectTransposeRule
RIGHT_PROJECT_INCLUDE_OUTER
-
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
-
Constructor Summary
Constructors Constructor Description JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description)
Creates a JoinProjectTransposeRule with default factory.JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description, boolean includeOuter, RelFactories.ProjectFactory projectFactory)
Deprecated.JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description, boolean includeOuter, RelBuilderFactory relBuilderFactory)
Creates a JoinProjectTransposeRule.JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description, RelFactories.ProjectFactory projectFactory)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createProjectExprs(Project projRel, RelNode joinChild, int adjustmentAmount, RexBuilder rexBuilder, java.util.List<RelDataTypeField> joinChildrenFields, java.util.List<Pair<RexNode,java.lang.String>> projects)
Creates projection expressions corresponding to one of the inputs into the joinprotected RelNode
getProjectChild(RelOptRuleCall call, Project project, boolean leftChild)
Returns the child of the project that will be used as input into the new LogicalJoin once the projects are pulled above the LogicalJoin.protected Project
getRightChild(RelOptRuleCall call)
protected boolean
hasLeftChild(RelOptRuleCall call)
protected boolean
hasRightChild(RelOptRuleCall call)
void
onMatch(RelOptRuleCall call)
Receives notification about a rule match.-
Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
-
-
-
Field Detail
-
BOTH_PROJECT
public static final JoinProjectTransposeRule BOTH_PROJECT
-
LEFT_PROJECT
public static final JoinProjectTransposeRule LEFT_PROJECT
-
RIGHT_PROJECT
public static final JoinProjectTransposeRule RIGHT_PROJECT
-
BOTH_PROJECT_INCLUDE_OUTER
public static final JoinProjectTransposeRule BOTH_PROJECT_INCLUDE_OUTER
-
LEFT_PROJECT_INCLUDE_OUTER
public static final JoinProjectTransposeRule LEFT_PROJECT_INCLUDE_OUTER
-
RIGHT_PROJECT_INCLUDE_OUTER
public static final JoinProjectTransposeRule RIGHT_PROJECT_INCLUDE_OUTER
-
includeOuter
private final boolean includeOuter
-
-
Constructor Detail
-
JoinProjectTransposeRule
public JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description, boolean includeOuter, RelBuilderFactory relBuilderFactory)
Creates a JoinProjectTransposeRule.
-
JoinProjectTransposeRule
public JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description)
Creates a JoinProjectTransposeRule with default factory.
-
JoinProjectTransposeRule
@Deprecated public JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description, RelFactories.ProjectFactory projectFactory)
Deprecated.
-
JoinProjectTransposeRule
@Deprecated public JoinProjectTransposeRule(RelOptRuleOperand operand, java.lang.String description, boolean includeOuter, RelFactories.ProjectFactory projectFactory)
Deprecated.
-
-
Method Detail
-
onMatch
public void onMatch(RelOptRuleCall call)
Description copied from class:RelOptRule
Receives notification about a rule match. At the time that this method is called,call.rels
holds the set of relational expressions which match the operands to the rule;call.rels[0]
is the root expression.Typically a rule would check that the nodes are valid matches, creates a new expression, then calls back
RelOptRuleCall.transformTo(org.apache.calcite.rel.RelNode, java.util.Map<org.apache.calcite.rel.RelNode, org.apache.calcite.rel.RelNode>)
to register the expression.- Specified by:
onMatch
in classRelOptRule
- Parameters:
call
- Rule call- See Also:
RelOptRule.matches(RelOptRuleCall)
-
hasLeftChild
protected boolean hasLeftChild(RelOptRuleCall call)
- Parameters:
call
- RelOptRuleCall- Returns:
- true if the rule was invoked with a left project child
-
hasRightChild
protected boolean hasRightChild(RelOptRuleCall call)
- Parameters:
call
- RelOptRuleCall- Returns:
- true if the rule was invoked with 2 children
-
getRightChild
protected Project getRightChild(RelOptRuleCall call)
- Parameters:
call
- RelOptRuleCall- Returns:
- LogicalProject corresponding to the right child
-
getProjectChild
protected RelNode getProjectChild(RelOptRuleCall call, Project project, boolean leftChild)
Returns the child of the project that will be used as input into the new LogicalJoin once the projects are pulled above the LogicalJoin.- Parameters:
call
- RelOptRuleCallproject
- project RelNodeleftChild
- true if the project corresponds to the left projection- Returns:
- child of the project that will be used as input into the new LogicalJoin once the projects are pulled above the LogicalJoin
-
createProjectExprs
protected void createProjectExprs(Project projRel, RelNode joinChild, int adjustmentAmount, RexBuilder rexBuilder, java.util.List<RelDataTypeField> joinChildrenFields, java.util.List<Pair<RexNode,java.lang.String>> projects)
Creates projection expressions corresponding to one of the inputs into the join- Parameters:
projRel
- the projection input into the join (if it exists)joinChild
- the child of the projection input (if there is a projection); otherwise, this is the join inputadjustmentAmount
- the amount the expressions need to be shifted byrexBuilder
- rex builderjoinChildrenFields
- concatenation of the fields from the left and right join inputs (once the projections have been removed)projects
- Projection expressions & names to be created
-
-