Class FlinkBushyJoinReorderRule

java.lang.Object
org.apache.calcite.plan.RelOptRule
org.apache.calcite.plan.RelRule<FlinkBushyJoinReorderRule.Config>
org.apache.flink.table.planner.plan.rules.logical.FlinkBushyJoinReorderRule
All Implemented Interfaces:
org.apache.calcite.rel.rules.TransformationRule

@Enclosing public class FlinkBushyJoinReorderRule extends org.apache.calcite.plan.RelRule<FlinkBushyJoinReorderRule.Config> implements org.apache.calcite.rel.rules.TransformationRule
Flink bushy join reorder rule, which will convert MultiJoin to a bushy join tree.

In this bushy join reorder strategy, the join reorder step is as follows:

First step, we will reorder all the inner join type inputs in the multiJoin. We adopt the concept of level in dynamic programming, and the latter layer will use the results stored in the previous levels. First, we put all input factor (each input factor in MultiJoin) into level 0, then we build all two-inputs join at level 1 based on the FlinkCost of level 0, then we will build three-inputs join based on the previous two levels, then four-inputs joins ... etc, util we reorder all the inner join type input factors in the multiJoin. When building m-inputs join, we only keep the best plan (have the lowest FlinkCost) for the same set of m inputs. E.g., for three-inputs join, we keep only the best plan for inputs {A, B, C} among plans (A J B) J C, (A J C) J B, (B J C) J A.

Second step, we will add all outer join factors to the top of reordered join tree generated by the first step. E.g., for the example (((A LJ B) IJ C) IJ D). we will first reorder A, C and D using the first step strategy, get ((A IJ C) IJ D). Then, we will add B to the top, get (((A IJ C) IJ D) LJ B).

Third step, we will add all cross join factors whose join condition is true to the top in the final step.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Rule configuration.

    Nested classes/interfaces inherited from class org.apache.calcite.plan.RelRule

    org.apache.calcite.plan.RelRule.Done, org.apache.calcite.plan.RelRule.MatchHandler<R extends org.apache.calcite.plan.RelOptRule>, org.apache.calcite.plan.RelRule.OperandBuilder, org.apache.calcite.plan.RelRule.OperandDetailBuilder<R extends org.apache.calcite.rel.RelNode>, org.apache.calcite.plan.RelRule.OperandTransform

    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.RelRule

    config

    Fields inherited from class org.apache.calcite.plan.RelOptRule

    description, operands, relBuilderFactory
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    FlinkBushyJoinReorderRule(org.apache.calcite.rel.core.RelFactories.JoinFactory joinFactory, org.apache.calcite.rel.core.RelFactories.ProjectFactory projectFactory, org.apache.calcite.rel.core.RelFactories.FilterFactory filterFactory)
    Deprecated.
     
    FlinkBushyJoinReorderRule(org.apache.calcite.tools.RelBuilderFactory relBuilderFactory)
    Deprecated.
    protected
    Creates a FlinkBushyJoinReorderRule.
  • Method Summary

    Modifier and Type
    Method
    Description
    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, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FlinkBushyJoinReorderRule

      protected FlinkBushyJoinReorderRule(FlinkBushyJoinReorderRule.Config config)
      Creates a FlinkBushyJoinReorderRule.
    • FlinkBushyJoinReorderRule

      @Deprecated public FlinkBushyJoinReorderRule(org.apache.calcite.tools.RelBuilderFactory relBuilderFactory)
      Deprecated.
    • FlinkBushyJoinReorderRule

      @Deprecated public FlinkBushyJoinReorderRule(org.apache.calcite.rel.core.RelFactories.JoinFactory joinFactory, org.apache.calcite.rel.core.RelFactories.ProjectFactory projectFactory, org.apache.calcite.rel.core.RelFactories.FilterFactory filterFactory)
      Deprecated.
  • Method Details

    • onMatch

      public void onMatch(org.apache.calcite.plan.RelOptRuleCall call)
      Specified by:
      onMatch in class org.apache.calcite.plan.RelOptRule