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
FieldsModifier and TypeFieldDescriptionprotected final CorrelationIdprotected final com.google.common.collect.ImmutableList<RelHint>protected final JoinRelTypeprotected final ImmutableBitSetFields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCorrelate(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 Summary
Modifier 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.BiRel
childrenAccept, getInputs, getLeft, getRight, replaceInputMethods 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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.calcite.rel.hint.Hintable
attachHints, withHintsMethods 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: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 interfaceRelNode- Overrides:
isValidin classAbstractRelNode- Parameters:
litmus- What to do if invalidcontext- Context for validity checking- Returns:
- Whether relational expression is valid
-
copy
Description 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 interfaceRelNode- Overrides:
copyin 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:
deriveRowTypein classAbstractRelNode
-
explainTerms
Description 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 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: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 interfaceRelNode- Overrides:
getCorrelVariablein 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: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 interfaceRelNode- Overrides:
getVariablesSetin classAbstractRelNode- Returns:
- Names of variables which are set in this relational expression
-
estimateRowCount
Description 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 interfaceRelNode- Overrides:
estimateRowCountin classAbstractRelNode- Parameters:
mq- Metadata query- Returns:
- Estimate of the number of rows this relational expression will return
-
computeSelfCost
Description 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 interfaceRelNode- Overrides:
computeSelfCostin classAbstractRelNode- Parameters:
planner- Planner for cost calculationmq- Metadata query- Returns:
- Cost of this plan (not including children)
-
getHints
Description copied from interface:HintableReturns the hints of this relational expressions as an immutable list.
-