Class Join
- java.lang.Object
-
- org.apache.calcite.rel.AbstractRelNode
-
- org.apache.calcite.rel.BiRel
-
- org.apache.calcite.rel.core.Join
-
- All Implemented Interfaces:
java.lang.Cloneable
,RelOptNode
,RelNode
- Direct Known Subclasses:
Bindables.BindableJoin
,EnumerableThetaJoin
,EquiJoin
,JdbcRules.JdbcJoin
,LogicalJoin
,PigJoin
public abstract class Join extends BiRel
Relational expression that combines two relational expressions according to some condition.Each output row has columns from the left and right inputs. The set of output rows is a subset of the cartesian product of the two inputs; precisely which subset depends on the join condition.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
-
Field Summary
Fields Modifier and Type Field Description protected RexNode
condition
protected JoinRelType
joinType
Values must be of enumerationJoinRelType
, except thatJoinRelType.RIGHT
is disallowed.protected com.google.common.collect.ImmutableSet<CorrelationId>
variablesSet
-
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Join(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, RexNode condition, java.util.Set<CorrelationId> variablesSet, JoinRelType joinType)
Creates a Join.protected
Join(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, RexNode condition, JoinRelType joinType, java.util.Set<java.lang.String> variablesStopped)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RelNode
accept(RexShuttle shuttle)
Accepts a visit from a shuttle.JoinInfo
analyzeCondition()
Analyzes the join condition.RelOptCost
computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
Returns the cost of this plan (not including children).Join
copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
Creates a copy of this relational expression, perhaps changing traits and inputs.abstract Join
copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone)
Creates a copy of this join, overriding condition, system fields and inputs.static RelDataType
createJoinType(RelDataTypeFactory typeFactory, RelDataType leftType, RelDataType rightType, java.util.List<java.lang.String> fieldNameList, java.util.List<RelDataTypeField> systemFieldList)
Deprecated.static RelDataType
deriveJoinRowType(RelDataType leftType, RelDataType rightType, JoinRelType joinType, RelDataTypeFactory typeFactory, java.util.List<java.lang.String> fieldNameList, java.util.List<RelDataTypeField> systemFieldList)
Deprecated.protected RelDataType
deriveRowType()
static double
estimateJoinedRows(Join joinRel, RexNode condition)
Deprecated.double
estimateRowCount(RelMetadataQuery mq)
Returns an estimate of the number of rows this relational expression will return.RelWriter
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.java.util.List<RexNode>
getChildExps()
Returns a list of this relational expression's child expressions.RexNode
getCondition()
JoinRelType
getJoinType()
java.util.List<RelDataTypeField>
getSystemFieldList()
Returns a list of system fields that will be prefixed to output row type.java.util.Set<CorrelationId>
getVariablesSet()
Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.boolean
isSemiJoinDone()
Returns whether this LogicalJoin has already spawned aSemiJoin
viaJoinAddRedundantSemiJoinRule
.boolean
isValid(Litmus litmus, RelNode.Context context)
Returns whether this relational expression is valid.-
Methods inherited from class org.apache.calcite.rel.BiRel
childrenAccept, getInputs, getLeft, getRight, replaceInput
-
Methods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, collectVariablesSet, collectVariablesUsed, computeDigest, computeSelfCost, explain, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraitSet, getVariablesStopped, isDistinct, isKey, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
-
-
-
-
Field Detail
-
condition
protected final RexNode condition
-
variablesSet
protected final com.google.common.collect.ImmutableSet<CorrelationId> variablesSet
-
joinType
protected final JoinRelType joinType
Values must be of enumerationJoinRelType
, except thatJoinRelType.RIGHT
is disallowed.
-
-
Constructor Detail
-
Join
protected Join(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, RexNode condition, java.util.Set<CorrelationId> variablesSet, JoinRelType joinType)
Creates a Join.Note: We plan to change the
variablesStopped
parameter toSet<CorrelationId> variablesSet
before version 2.0
, becausegetVariablesSet()
is preferred overAbstractRelNode.getVariablesStopped()
. This constructor is not deprecated, for now, because maintaining overloaded constructors in multiple sub-classes would be onerous.- Parameters:
cluster
- ClustertraitSet
- Trait setleft
- Left inputright
- Right inputcondition
- Join conditionjoinType
- Join typevariablesSet
- Set variables that are set by the LHS and used by the RHS and are not available to nodes above this Join in the tree
-
Join
@Deprecated protected Join(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, RexNode condition, JoinRelType joinType, java.util.Set<java.lang.String> variablesStopped)
Deprecated.
-
-
Method Detail
-
getChildExps
public java.util.List<RexNode> getChildExps()
Description copied from interface:RelNode
Returns a list of this relational expression's child expressions. (These are scalar expressions, and so do not include the relational inputs that are returned byRelNode.getInputs()
.The caller should treat the list as unmodifiable; typical implementations will return an immutable list. If there are no child expressions, returns an empty list, not
null
.- Specified by:
getChildExps
in interfaceRelNode
- Overrides:
getChildExps
in classAbstractRelNode
- Returns:
- List of this relational expression's child expressions
- See Also:
RelNode.accept(org.apache.calcite.rex.RexShuttle)
-
accept
public RelNode accept(RexShuttle shuttle)
Description copied from interface:RelNode
Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created.- Specified by:
accept
in interfaceRelNode
- Overrides:
accept
in classAbstractRelNode
- Parameters:
shuttle
- Shuttle- Returns:
- A copy of this node incorporating changes made by the shuttle to this node's children
-
getCondition
public RexNode getCondition()
-
getJoinType
public JoinRelType getJoinType()
-
isValid
public boolean isValid(Litmus litmus, RelNode.Context context)
Description copied from interface:RelNode
Returns whether this relational expression is valid.If assertions are enabled, this method is typically called with
litmus
=THROW
, as follows:assert rel.isValid(Litmus.THROW)
This signals that the method can throw an
AssertionError
if it is not valid.- Specified by:
isValid
in interfaceRelNode
- Overrides:
isValid
in classAbstractRelNode
- Parameters:
litmus
- What to do if invalidcontext
- Context for validity checking- Returns:
- Whether relational expression is valid
-
computeSelfCost
public 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 interfaceRelNode
- Overrides:
computeSelfCost
in classAbstractRelNode
- Parameters:
planner
- Planner for cost calculationmq
- Metadata query- Returns:
- Cost of this plan (not including children)
-
estimateJoinedRows
@Deprecated public static double estimateJoinedRows(Join joinRel, RexNode condition)
Deprecated.
-
estimateRowCount
public double estimateRowCount(RelMetadataQuery mq)
Description copied from interface:RelNode
Returns an estimate of the number of rows this relational expression will return.NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
RelMetadataQuery.getRowCount(org.apache.calcite.rel.RelNode)
, which gives plugins a chance to override the rel's default ideas about row count.- Specified by:
estimateRowCount
in interfaceRelNode
- Overrides:
estimateRowCount
in classAbstractRelNode
- Parameters:
mq
- Metadata query- Returns:
- Estimate of the number of rows this relational expression will return
-
getVariablesSet
public java.util.Set<CorrelationId> getVariablesSet()
Description copied from interface:RelNode
Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.Note: only
Correlate
should set variables.- Specified by:
getVariablesSet
in interfaceRelNode
- Overrides:
getVariablesSet
in classAbstractRelNode
- Returns:
- Names of variables which are set in this relational expression
-
explainTerms
public RelWriter explainTerms(RelWriter pw)
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriterImpl.input(String, RelNode)
andRelWriterImpl.item(String, Object)
methods for each input and attribute.- Overrides:
explainTerms
in classBiRel
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
deriveRowType
protected RelDataType deriveRowType()
- Overrides:
deriveRowType
in classAbstractRelNode
-
isSemiJoinDone
public boolean isSemiJoinDone()
Returns whether this LogicalJoin has already spawned aSemiJoin
viaJoinAddRedundantSemiJoinRule
.The base implementation returns false.
- Returns:
- whether this join has already spawned a semi join
-
getSystemFieldList
public java.util.List<RelDataTypeField> getSystemFieldList()
Returns a list of system fields that will be prefixed to output row type.- Returns:
- list of system fields
-
deriveJoinRowType
@Deprecated public static RelDataType deriveJoinRowType(RelDataType leftType, RelDataType rightType, JoinRelType joinType, RelDataTypeFactory typeFactory, java.util.List<java.lang.String> fieldNameList, java.util.List<RelDataTypeField> systemFieldList)
Deprecated.
-
createJoinType
@Deprecated public static RelDataType createJoinType(RelDataTypeFactory typeFactory, RelDataType leftType, RelDataType rightType, java.util.List<java.lang.String> fieldNameList, java.util.List<RelDataTypeField> systemFieldList)
Deprecated.
-
copy
public final Join copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
Description copied from interface:RelNode
Creates a copy of this relational expression, perhaps changing traits and inputs.Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.
- Specified by:
copy
in interfaceRelNode
- Overrides:
copy
in classAbstractRelNode
- Parameters:
traitSet
- Trait setinputs
- Inputs- Returns:
- Copy of this relational expression, substituting traits and inputs
-
copy
public abstract Join copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone)
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>)
.- Parameters:
traitSet
- TraitsconditionExpr
- Conditionleft
- Left inputright
- Right inputjoinType
- Join typesemiJoinDone
- Whether this join has been translated to a semi-join- Returns:
- Copy of this join
-
analyzeCondition
public JoinInfo analyzeCondition()
Analyzes the join condition.- Returns:
- Analyzed join condition
-
-