public abstract class Correlate
extends org.apache.calcite.rel.BiRel
implements org.apache.calcite.rel.hint.Hintable
Temporarily copy from calcite to cherry-pick [CALCITE-5107] and will be removed when upgrade the latest calcite.
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) |
CorrelationId
Modifier and Type | Field and Description |
---|---|
protected org.apache.calcite.rel.core.CorrelationId |
correlationId |
protected com.google.common.collect.ImmutableList<org.apache.calcite.rel.hint.RelHint> |
hints |
protected org.apache.calcite.rel.core.JoinRelType |
joinType |
protected org.apache.calcite.util.ImmutableBitSet |
requiredColumns |
Modifier | Constructor and Description |
---|---|
protected |
Correlate(org.apache.calcite.rel.RelInput input)
Creates a Correlate by parsing serialized output.
|
protected |
Correlate(org.apache.calcite.plan.RelOptCluster cluster,
org.apache.calcite.plan.RelTraitSet traitSet,
List<org.apache.calcite.rel.hint.RelHint> hints,
org.apache.calcite.rel.RelNode left,
org.apache.calcite.rel.RelNode right,
org.apache.calcite.rel.core.CorrelationId correlationId,
org.apache.calcite.util.ImmutableBitSet requiredColumns,
org.apache.calcite.rel.core.JoinRelType joinType)
Creates a Correlate.
|
protected |
Correlate(org.apache.calcite.plan.RelOptCluster cluster,
org.apache.calcite.plan.RelTraitSet traitSet,
org.apache.calcite.rel.RelNode left,
org.apache.calcite.rel.RelNode right,
org.apache.calcite.rel.core.CorrelationId correlationId,
org.apache.calcite.util.ImmutableBitSet requiredColumns,
org.apache.calcite.rel.core.JoinRelType joinType)
Creates a Correlate.
|
Modifier and Type | Method and Description |
---|---|
@Nullable org.apache.calcite.plan.RelOptCost |
computeSelfCost(org.apache.calcite.plan.RelOptPlanner planner,
org.apache.calcite.rel.metadata.RelMetadataQuery mq) |
Correlate |
copy(org.apache.calcite.plan.RelTraitSet traitSet,
List<org.apache.calcite.rel.RelNode> inputs) |
abstract Correlate |
copy(org.apache.calcite.plan.RelTraitSet traitSet,
org.apache.calcite.rel.RelNode left,
org.apache.calcite.rel.RelNode right,
org.apache.calcite.rel.core.CorrelationId correlationId,
org.apache.calcite.util.ImmutableBitSet requiredColumns,
org.apache.calcite.rel.core.JoinRelType joinType) |
protected org.apache.calcite.rel.type.RelDataType |
deriveRowType() |
double |
estimateRowCount(org.apache.calcite.rel.metadata.RelMetadataQuery mq) |
org.apache.calcite.rel.RelWriter |
explainTerms(org.apache.calcite.rel.RelWriter pw) |
org.apache.calcite.rel.core.CorrelationId |
getCorrelationId()
Returns the correlating expressions.
|
String |
getCorrelVariable() |
com.google.common.collect.ImmutableList<org.apache.calcite.rel.hint.RelHint> |
getHints() |
org.apache.calcite.rel.core.JoinRelType |
getJoinType() |
org.apache.calcite.util.ImmutableBitSet |
getRequiredColumns()
Returns the required columns in left relation required for the correlation in the right.
|
Set<org.apache.calcite.rel.core.CorrelationId> |
getVariablesSet() |
boolean |
isValid(org.apache.calcite.util.Litmus litmus,
org.apache.calcite.rel.RelNode.Context context) |
childrenAccept, getInputs, getLeft, getRight, replaceInput
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
protected final org.apache.calcite.rel.core.CorrelationId correlationId
protected final org.apache.calcite.util.ImmutableBitSet requiredColumns
protected final org.apache.calcite.rel.core.JoinRelType joinType
protected final com.google.common.collect.ImmutableList<org.apache.calcite.rel.hint.RelHint> hints
protected Correlate(org.apache.calcite.plan.RelOptCluster cluster, org.apache.calcite.plan.RelTraitSet traitSet, List<org.apache.calcite.rel.hint.RelHint> hints, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.CorrelationId correlationId, org.apache.calcite.util.ImmutableBitSet requiredColumns, org.apache.calcite.rel.core.JoinRelType joinType)
cluster
- Cluster this relational expression belongs tohints
- Hints for this nodeleft
- 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 typeprotected Correlate(org.apache.calcite.plan.RelOptCluster cluster, org.apache.calcite.plan.RelTraitSet traitSet, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.CorrelationId correlationId, org.apache.calcite.util.ImmutableBitSet requiredColumns, org.apache.calcite.rel.core.JoinRelType joinType)
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 typeprotected Correlate(org.apache.calcite.rel.RelInput input)
input
- Input representationpublic boolean isValid(org.apache.calcite.util.Litmus litmus, org.apache.calcite.rel.RelNode.Context context)
isValid
in interface org.apache.calcite.rel.RelNode
isValid
in class org.apache.calcite.rel.AbstractRelNode
public Correlate copy(org.apache.calcite.plan.RelTraitSet traitSet, List<org.apache.calcite.rel.RelNode> inputs)
copy
in interface org.apache.calcite.rel.RelNode
copy
in class org.apache.calcite.rel.AbstractRelNode
public abstract Correlate copy(org.apache.calcite.plan.RelTraitSet traitSet, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.CorrelationId correlationId, org.apache.calcite.util.ImmutableBitSet requiredColumns, org.apache.calcite.rel.core.JoinRelType joinType)
public org.apache.calcite.rel.core.JoinRelType getJoinType()
protected org.apache.calcite.rel.type.RelDataType deriveRowType()
deriveRowType
in class org.apache.calcite.rel.AbstractRelNode
public org.apache.calcite.rel.RelWriter explainTerms(org.apache.calcite.rel.RelWriter pw)
explainTerms
in class org.apache.calcite.rel.BiRel
public org.apache.calcite.rel.core.CorrelationId getCorrelationId()
public String getCorrelVariable()
getCorrelVariable
in interface org.apache.calcite.rel.RelNode
getCorrelVariable
in class org.apache.calcite.rel.AbstractRelNode
public org.apache.calcite.util.ImmutableBitSet getRequiredColumns()
public Set<org.apache.calcite.rel.core.CorrelationId> getVariablesSet()
getVariablesSet
in interface org.apache.calcite.rel.RelNode
getVariablesSet
in class org.apache.calcite.rel.AbstractRelNode
public double estimateRowCount(org.apache.calcite.rel.metadata.RelMetadataQuery mq)
estimateRowCount
in interface org.apache.calcite.rel.RelNode
estimateRowCount
in class org.apache.calcite.rel.AbstractRelNode
public @Nullable org.apache.calcite.plan.RelOptCost computeSelfCost(org.apache.calcite.plan.RelOptPlanner planner, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
computeSelfCost
in interface org.apache.calcite.rel.RelNode
computeSelfCost
in class org.apache.calcite.rel.AbstractRelNode
public com.google.common.collect.ImmutableList<org.apache.calcite.rel.hint.RelHint> getHints()
getHints
in interface org.apache.calcite.rel.hint.Hintable
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.