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 SummaryNested classes/interfaces inherited from interface org.apache.calcite.rel.RelNodeRelNode.Context
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final CorrelationIdprotected final com.google.common.collect.ImmutableList<RelHint>protected final JoinRelTypeprotected final ImmutableBitSetFields inherited from class org.apache.calcite.rel.AbstractRelNodedigest, id, rowType, traitSet
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCorrelate(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) Creates a Correlate.protectedCorrelate(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) Deprecated.protectedCreates a Correlate by parsing serialized output.
- 
Method SummaryModifier and TypeMethodDescription@Nullable RelOptCostcomputeSelfCost(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 Correlatecopy(RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) protected RelDataTypedoubleReturns 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.booleanisValid(Litmus litmus, @Nullable RelNode.Context context) Returns whether this relational expression is valid.Methods inherited from class org.apache.calcite.rel.BiRelchildrenAccept, getInputs, getLeft, getRight, replaceInputMethods inherited from class org.apache.calcite.rel.AbstractRelNodeaccept, 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, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.calcite.rel.hint.HintableattachHints, withHintsMethods inherited from interface org.apache.calcite.rel.RelNodeexplain, fieldIsNullable, stripped
- 
Field Details- 
correlationId
- 
requiredColumns
- 
joinType
- 
hints
 
- 
- 
Constructor Details- 
Correlateprotected 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 to
- left- Left input relational expression
- right- Right input relational expression
- correlationId- Variable name for the row of left input
- requiredColumns- Set of columns that are used by correlation
- joinType- Join type
 
- 
Correlate@Deprecated protected Correlate(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) Deprecated.
- 
CorrelateCreates a Correlate by parsing serialized output.- Parameters:
- input- Input representation
 
 
- 
- 
Method Details- 
isValidDescription copied from interface:RelNodeReturns 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 AssertionErrorif it is not valid.- Specified by:
- isValidin interface- RelNode
- Overrides:
- isValidin class- AbstractRelNode
- Parameters:
- litmus- What to do if invalid
- context- Context for validity checking
- Returns:
- Whether relational expression is valid
 
- 
copyDescription copied from interface:RelNodeCreates 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:
- copyin interface- RelNode
- Overrides:
- copyin class- AbstractRelNode
- Parameters:
- traitSet- Trait set
- inputs- Inputs
- Returns:
- Copy of this relational expression, substituting traits and inputs
 
- 
copypublic abstract Correlate copy(RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType) 
- 
getJoinType
- 
deriveRowType- Overrides:
- deriveRowTypein class- AbstractRelNode
 
- 
explainTermsDescription copied from class:AbstractRelNodeDescribes 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:
- explainTermsin class- BiRel
- Parameters:
- pw- Plan writer
- Returns:
- Plan writer for fluent-explain pattern
 
- 
getCorrelationIdReturns the correlating expressions.- Returns:
- correlating expressions
 
- 
getCorrelVariableDescription copied from interface:RelNodeReturns 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:
- getCorrelVariablein interface- RelNode
- Overrides:
- getCorrelVariablein class- AbstractRelNode
- Returns:
- Name of correlating variable, or null
 
- 
getRequiredColumnsReturns 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
 
- 
getVariablesSetDescription copied from interface:RelNodeReturns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.- Specified by:
- getVariablesSetin interface- RelNode
- Overrides:
- getVariablesSetin class- AbstractRelNode
- Returns:
- Names of variables which are set in this relational expression
 
- 
estimateRowCountDescription copied from interface:RelNodeReturns 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:
- estimateRowCountin interface- RelNode
- Overrides:
- estimateRowCountin class- AbstractRelNode
- Parameters:
- mq- Metadata query
- Returns:
- Estimate of the number of rows this relational expression will return
 
- 
computeSelfCostDescription copied from interface:RelNodeReturns 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:
- computeSelfCostin interface- RelNode
- Overrides:
- computeSelfCostin class- AbstractRelNode
- Parameters:
- planner- Planner for cost calculation
- mq- Metadata query
- Returns:
- Cost of this plan (not including children)
 
- 
getHintsDescription copied from interface:HintableReturns the hints of this relational expressions as an immutable list.
 
-