Class Correlate
- All Implemented Interfaces:
Cloneable
,RelOptNode
,Hintable
,RelNode
- Direct Known Subclasses:
EnumerableCorrelate
,LogicalCorrelate
,SqlToRelTestBase.CustomCorrelate
It behaves like a kind of Join
,
but works by setting variables in its environment and restarting its
right-hand input.
Correlate is not a join since: typical rules should not match Correlate.
A Correlate is used to represent a correlated query. One implementation strategy is to de-correlate the expression.
Physical operation | Logical operation |
---|---|
NestedLoops | Correlate(A, B, regular) |
NestedLoopsOuter | Correlate(A, B, outer) |
NestedLoopsSemi | Correlate(A, B, semi) |
NestedLoopsAnti | Correlate(A, B, anti) |
HashJoin | EquiJoin(A, B) |
HashJoinOuter | EquiJoin(A, B, outer) |
HashJoinSemi | SemiJoin(A, B, semi) |
HashJoinAnti | SemiJoin(A, B, anti) |
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
Field Summary
Modifier and TypeFieldDescriptionprotected final CorrelationId
protected final com.google.common.collect.ImmutableList<RelHint>
protected final JoinRelType
protected final ImmutableBitSet
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet
-
Constructor Summary
ModifierConstructorDescriptionprotected
Correlate
(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) Creates a Correlate.protected
Correlate
(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) Deprecated.protected
Creates a Correlate by parsing serialized output. -
Method Summary
Modifier and TypeMethodDescription@Nullable RelOptCost
computeSelfCost
(RelOptPlanner planner, RelMetadataQuery mq) Returns the cost of this plan (not including children).copy
(RelTraitSet traitSet, List<RelNode> inputs) Creates a copy of this relational expression, perhaps changing traits and inputs.abstract Correlate
copy
(RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) protected RelDataType
double
Returns an estimate of the number of rows this relational expression will return.Describes the inputs and attributes of this relational expression.Returns the correlating expressions.Returns the name of the variable which is to be implicitly set at runtime each time a row is returned from the first input of this relational expression; or null if there is no variable.com.google.common.collect.ImmutableList<RelHint>
getHints()
Returns the hints of this relational expressions as an immutable list.Returns the required columns in left relation required for the correlation in the right.Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.boolean
isValid
(Litmus litmus, @Nullable 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, accept, collectVariablesSet, collectVariablesUsed, deepEquals, deepHashCode, equals, explain, getCluster, getConvention, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getRelDigest, getRelTypeName, getRowType, getTable, getTraitSet, hashCode, isEnforcer, metadata, onRegister, recomputeDigest, register, sole, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.calcite.rel.hint.Hintable
attachHints, withHints
Methods inherited from interface org.apache.calcite.rel.RelNode
explain, fieldIsNullable, stripped
-
Field Details
-
correlationId
-
requiredColumns
-
joinType
-
hints
-
-
Constructor Details
-
Correlate
protected Correlate(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) Creates a Correlate.- Parameters:
cluster
- Cluster this relational expression belongs toleft
- Left input relational expressionright
- Right input relational expressioncorrelationId
- Variable name for the row of left inputrequiredColumns
- Set of columns that are used by correlationjoinType
- Join type
-
Correlate
@Deprecated protected Correlate(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) Deprecated. -
Correlate
Creates a Correlate by parsing serialized output.- Parameters:
input
- Input representation
-
-
Method Details
-
isValid
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
-
copy
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 Correlate copy(RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) -
getJoinType
-
deriveRowType
- Overrides:
deriveRowType
in classAbstractRelNode
-
explainTerms
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriter.input(String, RelNode)
andRelWriter.item(String, Object)
methods for each input and attribute.- Overrides:
explainTerms
in classBiRel
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
getCorrelationId
Returns the correlating expressions.- Returns:
- correlating expressions
-
getCorrelVariable
Description copied from interface:RelNode
Returns the name of the variable which is to be implicitly set at runtime each time a row is returned from the first input of this relational expression; or null if there is no variable.- Specified by:
getCorrelVariable
in interfaceRelNode
- Overrides:
getCorrelVariable
in classAbstractRelNode
- Returns:
- Name of correlating variable, or null
-
getRequiredColumns
Returns the required columns in left relation required for the correlation in the right.- Returns:
- columns in left relation required for the correlation in the right
-
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.- Specified by:
getVariablesSet
in interfaceRelNode
- Overrides:
getVariablesSet
in classAbstractRelNode
- Returns:
- Names of variables which are set in this relational expression
-
estimateRowCount
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
-
computeSelfCost
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)
-
getHints
Description copied from interface:Hintable
Returns the hints of this relational expressions as an immutable list.
-