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
RelNode.Context
Modifier and Type | Field and Description |
---|---|
protected CorrelationId |
correlationId |
protected JoinRelType |
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 traitSet,
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,
SemiJoinType joinType)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
RelOptCost |
computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq)
Returns the cost of this plan (not including children).
|
Correlate |
copy(RelTraitSet traitSet,
java.util.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() |
RelWriter |
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.
|
CorrelationId |
getCorrelationId()
Returns the correlating expressions.
|
java.lang.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.
|
JoinRelType |
getJoinType() |
ImmutableBitSet |
getRequiredColumns()
Returns the required columns in left relation required for the correlation
in the right.
|
java.util.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,
RelNode.Context context)
Returns whether this relational expression is valid.
|
childrenAccept, getInputs, getLeft, getRight, replaceInput
accept, accept, collectVariablesSet, collectVariablesUsed, computeDigest, computeSelfCost, estimateRowCount, explain, getChildExps, getCluster, getCollationList, getConvention, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraitSet, getVariablesStopped, isDistinct, isKey, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
protected final CorrelationId correlationId
protected final ImmutableBitSet requiredColumns
protected final JoinRelType joinType
protected Correlate(RelOptCluster cluster, RelTraitSet traitSet, 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, SemiJoinType joinType)
public Correlate(RelInput input)
input
- Input representationpublic boolean isValid(Litmus litmus, RelNode.Context context)
RelNode
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 AssertionError
if it
is not valid.
isValid
in interface RelNode
isValid
in class AbstractRelNode
litmus
- What to do if invalidcontext
- Context for validity checkingpublic Correlate copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
RelNode
Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.
copy
in interface RelNode
copy
in class AbstractRelNode
traitSet
- 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 AbstractRelNode
public RelWriter explainTerms(RelWriter pw)
AbstractRelNode
super.explainTerms
, then call the
RelWriter.input(String, RelNode)
and
RelWriterImpl.item(String, Object)
methods for each input and attribute.explainTerms
in class BiRel
pw
- Plan writerpublic CorrelationId getCorrelationId()
public java.lang.String getCorrelVariable()
RelNode
getCorrelVariable
in interface RelNode
getCorrelVariable
in class AbstractRelNode
public ImmutableBitSet getRequiredColumns()
public java.util.Set<CorrelationId> getVariablesSet()
RelNode
Note: only Correlate
should set
variables.
getVariablesSet
in interface RelNode
getVariablesSet
in class AbstractRelNode
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
RelNode
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.
computeSelfCost
in interface RelNode
computeSelfCost
in class AbstractRelNode
planner
- Planner for cost calculationmq
- Metadata queryCopyright © 2012–2019 The Apache Software Foundation. All rights reserved.