Class Correlate
- java.lang.Object
-
- org.apache.calcite.rel.AbstractRelNode
-
- org.apache.calcite.rel.BiRel
-
- org.apache.calcite.rel.core.Correlate
-
- All Implemented Interfaces:
java.lang.Cloneable
,RelOptNode
,RelNode
- Direct Known Subclasses:
EnumerableCorrelate
,LogicalCorrelate
public abstract class Correlate extends BiRel
A relational operator that performs nested-loop joins.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.
Mapping of physical operations to logical ones 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:
CorrelationId
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
-
Field Summary
Fields Modifier and Type Field Description protected CorrelationId
correlationId
protected SemiJoinType
joinType
protected ImmutableBitSet
requiredColumns
-
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Correlate(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, SemiJoinType joinType)
Creates a Correlate.Correlate(RelInput input)
Creates a Correlate by parsing serialized output.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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, SemiJoinType 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.SemiJoinType
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.-
Methods inherited from class org.apache.calcite.rel.BiRel
childrenAccept, getInputs, getLeft, getRight, replaceInput
-
Methods inherited from class org.apache.calcite.rel.AbstractRelNode
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
-
-
-
-
Field Detail
-
correlationId
protected final CorrelationId correlationId
-
requiredColumns
protected final ImmutableBitSet requiredColumns
-
joinType
protected final SemiJoinType joinType
-
-
Constructor Detail
-
Correlate
protected Correlate(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, CorrelationId correlationId, ImmutableBitSet requiredColumns, SemiJoinType 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
public Correlate(RelInput input)
Creates a Correlate by parsing serialized output.- Parameters:
input
- Input representation
-
-
Method Detail
-
isValid
public boolean isValid(Litmus litmus, RelNode.Context context)
Description copied from interface:RelNode
Returns 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
AssertionError
if it is not valid.- Specified by:
isValid
in interfaceRelNode
- Overrides:
isValid
in classAbstractRelNode
- Parameters:
litmus
- What to do if invalidcontext
- Context for validity checking- Returns:
- Whether relational expression is valid
-
copy
public Correlate copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
Description copied from interface:RelNode
Creates 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:
copy
in interfaceRelNode
- Overrides:
copy
in 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, SemiJoinType joinType)
-
getJoinType
public SemiJoinType getJoinType()
-
deriveRowType
protected RelDataType deriveRowType()
- Overrides:
deriveRowType
in classAbstractRelNode
-
explainTerms
public RelWriter explainTerms(RelWriter pw)
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriterImpl.input(String, RelNode)
andRelWriterImpl.item(String, Object)
methods for each input and attribute.- Overrides:
explainTerms
in classBiRel
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
getCorrelationId
public CorrelationId getCorrelationId()
Returns the correlating expressions.- Returns:
- correlating expressions
-
getCorrelVariable
public java.lang.String getCorrelVariable()
Description copied from interface:RelNode
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.- Specified by:
getCorrelVariable
in interfaceRelNode
- Overrides:
getCorrelVariable
in classAbstractRelNode
- Returns:
- Name of correlating variable, or null
-
getRequiredColumns
public ImmutableBitSet 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
public java.util.Set<CorrelationId> getVariablesSet()
Description copied from interface:RelNode
Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.Note: only
Correlate
should set variables.- Specified by:
getVariablesSet
in interfaceRelNode
- Overrides:
getVariablesSet
in classAbstractRelNode
- Returns:
- Names of variables which are set in this relational expression
-
computeSelfCost
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
Description copied from interface:RelNode
Returns 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:
computeSelfCost
in interfaceRelNode
- Overrides:
computeSelfCost
in classAbstractRelNode
- Parameters:
planner
- Planner for cost calculationmq
- Metadata query- Returns:
- Cost of this plan (not including children)
-
-