org.eigenbase.rel.rules
Class PullUpProjectsOnTopOfMultiJoinRule

java.lang.Object
  extended by org.eigenbase.relopt.RelOptRule
      extended by org.eigenbase.rel.rules.PullUpProjectsAboveJoinRule
          extended by org.eigenbase.rel.rules.PullUpProjectsOnTopOfMultiJoinRule

public class PullUpProjectsOnTopOfMultiJoinRule
extends PullUpProjectsAboveJoinRule

PullUpProjectsOnTopOfMultiJoinRule implements the rule for pulling ProjectRels that are on top of a MultiJoinRel and beneath a JoinRel so the ProjectRel appears above the JoinRel. In the process of doing so, also save away information about the respective fields that are referenced in the expressions in the ProjectRel we're pulling up, as well as the join condition, in the resultant MultiJoinRels

For example, if we have the following subselect:

      (select X.x1, Y.y1 from X, Y
          where X.x2 = Y.y2 and X.x3 = 1 and Y.y3 = 2)

The MultiJoinRel associated with (X, Y) associates x1 with X and y1 with Y. Although x3 and y3 need to be read due to the filters, they are not required after the row scan has completed and therefore are not saved. The join fields, x2 and y2, are also tracked separately.

Note that by only pulling up projects that are on top of MultiJoinRels, we preserve projections on top of row scans.

See the superclass for details on restrictions regarding which ProjectRels cannot be pulled.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/rel/rules/PullUpProjectsOnTopOfMultiJoinRule.java#7 $
Author:
Zelaine Fong

Field Summary
static PullUpProjectsOnTopOfMultiJoinRule instanceLeftProjectChild
           
static PullUpProjectsOnTopOfMultiJoinRule instanceRightProjectChild
           
static PullUpProjectsOnTopOfMultiJoinRule instanceTwoProjectChildren
           
 
Fields inherited from class org.eigenbase.relopt.RelOptRule
ANY, description, operands
 
Constructor Summary
PullUpProjectsOnTopOfMultiJoinRule(RelOptRuleOperand operand, String description)
           
 
Method Summary
protected  RelNode getProjectChild(RelOptRuleCall call, ProjectRel project, boolean leftChild)
          Returns the child of the project that will be used as input into the new JoinRel once the projects are pulled above the JoinRel.
protected  ProjectRel getRightChild(RelOptRuleCall call)
           
protected  boolean hasLeftChild(RelOptRuleCall call)
           
protected  boolean hasRightChild(RelOptRuleCall call)
           
 
Methods inherited from class org.eigenbase.rel.rules.PullUpProjectsAboveJoinRule
onMatch
 
Methods inherited from class org.eigenbase.relopt.RelOptRule
convert, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, mergeTraitsAndConvert, mergeTraitsAndConvert, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

instanceTwoProjectChildren

public static final PullUpProjectsOnTopOfMultiJoinRule instanceTwoProjectChildren

instanceLeftProjectChild

public static final PullUpProjectsOnTopOfMultiJoinRule instanceLeftProjectChild

instanceRightProjectChild

public static final PullUpProjectsOnTopOfMultiJoinRule instanceRightProjectChild
Constructor Detail

PullUpProjectsOnTopOfMultiJoinRule

public PullUpProjectsOnTopOfMultiJoinRule(RelOptRuleOperand operand,
                                          String description)
Method Detail

hasLeftChild

protected boolean hasLeftChild(RelOptRuleCall call)
Overrides:
hasLeftChild in class PullUpProjectsAboveJoinRule
Parameters:
call - RelOptRuleCall
Returns:
true if the rule was invoked with a left project child

hasRightChild

protected boolean hasRightChild(RelOptRuleCall call)
Overrides:
hasRightChild in class PullUpProjectsAboveJoinRule
Parameters:
call - RelOptRuleCall
Returns:
true if the rule was invoked with 2 children

getRightChild

protected ProjectRel getRightChild(RelOptRuleCall call)
Overrides:
getRightChild in class PullUpProjectsAboveJoinRule
Parameters:
call - RelOptRuleCall
Returns:
ProjectRel corresponding to the right child

getProjectChild

protected RelNode getProjectChild(RelOptRuleCall call,
                                  ProjectRel project,
                                  boolean leftChild)
Description copied from class: PullUpProjectsAboveJoinRule
Returns the child of the project that will be used as input into the new JoinRel once the projects are pulled above the JoinRel.

Overrides:
getProjectChild in class PullUpProjectsAboveJoinRule
Parameters:
call - RelOptRuleCall
project - project RelNode
leftChild - true if the project corresponds to the left projection
Returns:
child of the project that will be used as input into the new JoinRel once the projects are pulled above the JoinRel