public abstract class Correlate extends BiRel implements Hintable
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) |
CorrelationIdRelNode.Context| Modifier and Type | Field and Description |
|---|---|
protected CorrelationId |
correlationId |
protected com.google.common.collect.ImmutableList<RelHint> |
hints |
protected JoinRelType |
joinType |
protected ImmutableBitSet |
requiredColumns |
digest, id, rowType, traitSet| Modifier | Constructor and Description |
|---|---|
protected |
Correlate(RelInput input)
Creates a Correlate by parsing serialized output.
|
protected |
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.
|
| Modifier and Type | Method and Description |
|---|---|
@Nullable RelOptCost |
computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq)
Returns the cost of this plan (not including children).
|
Correlate |
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 |
deriveRowType() |
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.
|
CorrelationId |
getCorrelationId()
Returns the correlating expressions.
|
String |
getCorrelVariable()
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.
|
JoinRelType |
getJoinType() |
ImmutableBitSet |
getRequiredColumns()
Returns the required columns in left relation required for the correlation
in the right.
|
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 |
isValid(Litmus litmus,
@Nullable RelNode.Context context)
Returns whether this relational expression is valid.
|
childrenAccept, getInputs, getLeft, getRight, replaceInputaccept, 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, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitattachHints, withHintsexplain, fieldIsNullableprotected final CorrelationId correlationId
protected final ImmutableBitSet requiredColumns
protected final JoinRelType joinType
protected final com.google.common.collect.ImmutableList<RelHint> hints
protected Correlate(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, 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 type@Deprecated protected Correlate(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType)
protected Correlate(RelInput input)
input - Input representationpublic boolean isValid(Litmus litmus, @Nullable RelNode.Context context)
RelNodeIf 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.
isValid in interface RelNodeisValid in class AbstractRelNodelitmus - What to do if invalidcontext - Context for validity checkingpublic Correlate copy(RelTraitSet traitSet, List<RelNode> inputs)
RelNodeSub-classes with other important attributes are encouraged to create variants of this method with more parameters.
copy in interface RelNodecopy in class AbstractRelNodetraitSet - Trait setinputs - Inputspublic abstract Correlate copy(RelTraitSet traitSet, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, JoinRelType joinType)
public JoinRelType getJoinType()
protected RelDataType deriveRowType()
deriveRowType in class AbstractRelNodepublic RelWriter explainTerms(RelWriter pw)
AbstractRelNodesuper.explainTerms, then call the
RelWriter.input(String, RelNode)
and
RelWriter.item(String, Object)
methods for each input and attribute.explainTerms in class BiRelpw - Plan writerpublic CorrelationId getCorrelationId()
public String getCorrelVariable()
RelNodegetCorrelVariable in interface RelNodegetCorrelVariable in class AbstractRelNodepublic ImmutableBitSet getRequiredColumns()
public Set<CorrelationId> getVariablesSet()
RelNodeNote: only Correlate should set
variables.
getVariablesSet in interface RelNodegetVariablesSet in class AbstractRelNodepublic double estimateRowCount(RelMetadataQuery mq)
RelNodeNOTE 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.
estimateRowCount in interface RelNodeestimateRowCount in class AbstractRelNodemq - Metadata querypublic @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
RelNodeNOTE 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.
computeSelfCost in interface RelNodecomputeSelfCost in class AbstractRelNodeplanner - Planner for cost calculationmq - Metadata queryCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.