Class JoinProjectTransposeRule

All Implemented Interfaces:
Direct Known Subclasses:

@Enclosing public class JoinProjectTransposeRule extends RelRule<JoinProjectTransposeRule.Config> implements TransformationRule
Planner rule that matches a Join one of whose inputs is a LogicalProject, and pulls the project up.

Projections are pulled up if the LogicalProject doesn't originate from a null generating input in an outer join.

  • Constructor Details

  • Method Details

    • 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>, org.apache.calcite.plan.RelHintsPropagator) to register the expression.

      Specified by:
      onMatch in class RelOptRule
      call - Rule call
      See Also:
    • hasLeftChild

      protected boolean hasLeftChild(RelOptRuleCall call)
      Returns whether the rule was invoked with a left project child.
    • hasRightChild

      protected boolean hasRightChild(RelOptRuleCall call)
      Returns whether the rule was invoked with 2 children.
    • getRightChild

      protected Project getRightChild(RelOptRuleCall call)
      Returns the Project 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.
      call - RelOptRuleCall
      project - project RelNode
      leftChild - true if the project corresponds to the left projection
      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(@Nullable Project project, RelNode joinChild, int adjustmentAmount, RexBuilder rexBuilder, List<RelDataTypeField> joinChildrenFields, List<Pair<RexNode,String>> projects)
      Creates projection expressions corresponding to one of the inputs into the join.
      project - 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 input
      adjustmentAmount - the amount the expressions need to be shifted by
      rexBuilder - rex builder
      joinChildrenFields - concatenation of the fields from the left and right join inputs (once the projections have been removed)
      projects - Projection expressions & names to be created