Class EnumerableMergeJoin

All Implemented Interfaces:
Cloneable, EnumerableRel, RelOptNode, Hintable, PhysicalNode, RelNode

public class EnumerableMergeJoin extends Join implements EnumerableRel
Implementation of Join in enumerable calling convention using a merge algorithm.
  • Constructor Details

  • Method Details

    • isMergeJoinSupported

      public static boolean isMergeJoinSupported(JoinRelType joinType)
    • passThroughTraits

      public @Nullable Pair<RelTraitSet,List<RelTraitSet>> passThroughTraits(RelTraitSet required)
      Pass collations through can have three cases:

      1. If sort keys are equal to either left join keys, or right join keys, collations can be pushed to both join sides with correct mappings. For example, for the query

      
          select * from foo join bar
              on foo.a=bar.b
          order by foo.a desc
       

      after traits pass through it will be equivalent to

      
          select * from
              (select * from foo order by foo.a desc)
              join
              (select * from bar order by bar.b desc)
       

      2. If sort keys are sub-set of either left join keys, or right join keys, collations have to be extended to cover all joins keys before passing through, because merge join requires all join keys are sorted. For example, for the query

      
          select * from foo join bar
              on foo.a=bar.b and foo.c=bar.d
          order by foo.a desc
       

      after traits pass through it will be equivalent to

      
          select * from
              (select * from foo order by foo.a desc, foo.c)
              join
              (select * from bar order by bar.b desc, bar.d)
       

      3. If sort keys are super-set of either left join keys, or right join keys, but not both, collations can be completely passed to the join key whose join keys match the prefix of collations. Meanwhile, partial mapped collations can be passed to another join side to make sure join keys are sorted. For example, for the query

      
          select * from foo join bar
              on foo.a=bar.b and foo.c=bar.d
              order by foo.a desc, foo.c desc, foo.e
       

      after traits pass through it will be equivalent to

      
          select * from
              (select * from foo order by foo.a desc, foo.c desc, foo.e)
              join
              (select * from bar order by bar.b desc, bar.d desc)
       
      Specified by:
      passThroughTraits in interface EnumerableRel
      Specified by:
      passThroughTraits in interface PhysicalNode
    • deriveTraits

      public @Nullable Pair<RelTraitSet,List<RelTraitSet>> deriveTraits(RelTraitSet childTraits, int childId)
      Description copied from interface: PhysicalNode
      Derive traitset from child node, returns a pair of traits after traits derivation.

      Pair.left: the new traitset; Pair.right: the list of required traitsets for child nodes.

      Specified by:
      deriveTraits in interface EnumerableRel
      Specified by:
      deriveTraits in interface PhysicalNode
    • getDeriveMode

      public DeriveMode getDeriveMode()
      Description copied from interface: PhysicalNode
      Returns mode of derivation.
      Specified by:
      getDeriveMode in interface EnumerableRel
      Specified by:
      getDeriveMode in interface PhysicalNode
    • create

      public static EnumerableMergeJoin create(RelNode left, RelNode right, RexNode condition, ImmutableIntList leftKeys, ImmutableIntList rightKeys, JoinRelType joinType)
    • copy

      public EnumerableMergeJoin copy(RelTraitSet traitSet, RexNode condition, RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone)
      Description copied from class: Join
      Creates a copy of this join, overriding condition, system fields and inputs.

      General contract as RelNode.copy(org.apache.calcite.plan.RelTraitSet, java.util.List<org.apache.calcite.rel.RelNode>).

      Specified by:
      copy in class Join
      Parameters:
      traitSet - Traits
      condition - Condition
      left - Left input
      right - Right input
      joinType - Join type
      semiJoinDone - Whether this join has been translated to a semi-join
      Returns:
      Copy of this join
    • computeSelfCost

      public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
      Description copied from interface: RelNode
      Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

      NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

      Specified by:
      computeSelfCost in interface RelNode
      Overrides:
      computeSelfCost in class Join
      Parameters:
      planner - Planner for cost calculation
      mq - Metadata query
      Returns:
      Cost of this plan (not including children)
    • implement

      Description copied from interface: EnumerableRel
      Creates a plan for this expression according to a calling convention.
      Specified by:
      implement in interface EnumerableRel
      Parameters:
      implementor - Implementor
      pref - Preferred representation for rows in result expression
      Returns:
      Plan for this expression according to a calling convention