public abstract class Correlate extends BiRel
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 CorrelationId |
correlationId |
protected SemiJoinType |
joinType |
protected ImmutableBitSet |
requiredColumns |
digest, id, rowType, traitSet| Modifier | Constructor and Description |
|---|---|
|
Correlate(RelInput input)
Creates a Correlate by parsing serialized output.
|
protected |
Correlate(RelOptCluster cluster,
RelTraitSet traits,
RelNode left,
RelNode right,
CorrelationId correlationId,
ImmutableBitSet requiredColumns,
SemiJoinType joinType)
Creates a Correlate.
|
| Modifier and Type | Method and Description |
|---|---|
RelOptCost |
computeSelfCost(RelOptPlanner planner)
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,
SemiJoinType joinType) |
protected RelDataType |
deriveRowType() |
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.
|
SemiJoinType |
getJoinType() |
ImmutableBitSet |
getRequiredColumns()
Returns the required columns in left relation required for the correlation
in the right.
|
Set<String> |
getVariablesStopped()
Returns the names of variables which are set in this relational
expression but also used and therefore not available to parents of this
relational expression.
|
childrenAccept, getInputs, getLeft, getRight, replaceInputaccept, accept, collectVariablesSet, collectVariablesUsed, computeDigest, explain, getChildExps, getCluster, getCollationList, getConvention, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraitSet, isDistinct, isKey, isValid, metadata, onRegister, recomputeDigest, register, sole, toStringprotected final CorrelationId correlationId
protected final ImmutableBitSet requiredColumns
protected final SemiJoinType joinType
protected Correlate(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, SemiJoinType 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 typepublic Correlate(RelInput input)
input - Input representationpublic 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, SemiJoinType joinType)
public SemiJoinType getJoinType()
protected RelDataType deriveRowType()
deriveRowType in class AbstractRelNodepublic RelWriter explainTerms(RelWriter pw)
AbstractRelNodesuper.explainTerms, then call the
RelWriterImpl.input(String, RelNode)
and
RelWriterImpl.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<String> getVariablesStopped()
RelNodeNote: only Correlate should set
variables
getVariablesStopped in interface RelNodegetVariablesStopped in class AbstractRelNodepublic RelOptCost computeSelfCost(RelOptPlanner planner)
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 calculationCopyright © 2012–2015 The Apache Software Foundation. All rights reserved.