Interface RelNode
-
- All Superinterfaces:
java.lang.Cloneable
,RelOptNode
- All Known Subinterfaces:
BindableRel
,Converter
,EnumerableRel
,InterpretableRel
,JdbcRel
,RelStructuredTypeFlattener.SelfFlatteningRel
- All Known Implementing Classes:
AbstractConverter
,AbstractRelNode
,Aggregate
,Bindables.BindableAggregate
,Bindables.BindableFilter
,Bindables.BindableJoin
,Bindables.BindableProject
,Bindables.BindableSort
,Bindables.BindableTableScan
,Bindables.BindableUnion
,Bindables.BindableValues
,Bindables.BindableWindow
,BiRel
,Calc
,Chi
,Collect
,ConverterImpl
,Correlate
,Delta
,EnumerableAggregate
,EnumerableBindable
,EnumerableCalc
,EnumerableCollect
,EnumerableCorrelate
,EnumerableFilter
,EnumerableInterpretable
,EnumerableInterpreter
,EnumerableIntersect
,EnumerableJoin
,EnumerableLimit
,EnumerableMergeJoin
,EnumerableMinus
,EnumerableProject
,EnumerableSemiJoin
,EnumerableSort
,EnumerableTableFunctionScan
,EnumerableTableModify
,EnumerableTableScan
,EnumerableThetaJoin
,EnumerableUncollect
,EnumerableUnion
,EnumerableValues
,EnumerableWindow
,EquiJoin
,EquiJoin
,Exchange
,Filter
,HepRelVertex
,InterpretableConverter
,Intersect
,JdbcRules.JdbcAggregate
,JdbcRules.JdbcCalc
,JdbcRules.JdbcFilter
,JdbcRules.JdbcIntersect
,JdbcRules.JdbcJoin
,JdbcRules.JdbcMinus
,JdbcRules.JdbcProject
,JdbcRules.JdbcSort
,JdbcRules.JdbcTableModify
,JdbcRules.JdbcUnion
,JdbcRules.JdbcValues
,JdbcTableScan
,JdbcToEnumerableConverter
,Join
,LogicalAggregate
,LogicalCalc
,LogicalChi
,LogicalCorrelate
,LogicalDelta
,LogicalExchange
,LogicalFilter
,LogicalIntersect
,LogicalJoin
,LogicalMatch
,LogicalMinus
,LogicalProject
,LogicalSort
,LogicalSortExchange
,LogicalTableFunctionScan
,LogicalTableModify
,LogicalTableScan
,LogicalUnion
,LogicalValues
,LogicalWindow
,Match
,Minus
,MultiJoin
,NoneConverter
,Project
,RelSubset
,Sample
,SemiJoin
,SetOp
,SingleRel
,Sort
,SortExchange
,StarTable.StarTableScan
,TableFunctionScan
,TableModify
,TableScan
,Uncollect
,Union
,Values
,Window
public interface RelNode extends RelOptNode, java.lang.Cloneable
ARelNode
is a relational expression.Relational expressions process data, so their names are typically verbs: Sort, Join, Project, Filter, Scan, Sample.
A relational expression is not a scalar expression; see
SqlNode
andRexNode
.If this type of relational expression has some particular planner rules, it should implement the public static method
AbstractRelNode.register(org.apache.calcite.plan.RelOptPlanner)
.When a relational expression comes to be implemented, the system allocates a
RelImplementor
to manage the process. Every implementable relational expression has aRelTraitSet
describing its physical attributes. The RelTraitSet always contains aConvention
describing how the expression passes data to its consuming relational expression, but may contain other traits, including some applied externally. Because traits can be applied externally, implementations of RelNode should never assume the size or contents of their trait set (beyond those traits configured by the RelNode itself).For each calling-convention, there is a corresponding sub-interface of RelNode. For example,
org.apache.calcite.adapter.enumerable.EnumerableRel
has operations to manage the conversion to a graph oforg.apache.calcite.adapter.enumerable.EnumerableConvention
calling-convention, and it interacts with aEnumerableRelImplementor
.A relational expression is only required to implement its calling-convention's interface when it is actually implemented, that is, converted into a plan/program. This means that relational expressions which cannot be implemented, such as converters, are not required to implement their convention's interface.
Every relational expression must derive from
AbstractRelNode
. (Why have theRelNode
interface, then? We need a root interface, because an interface can only derive from an interface.)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
RelNode.Context
Context of a relational expression, for purposes of checking validity.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description RelNode
accept(RelShuttle shuttle)
Accepts a visit from a shuttle.RelNode
accept(RexShuttle shuttle)
Accepts a visit from a shuttle.void
childrenAccept(RelVisitor visitor)
Interacts with theRelVisitor
in avisitor pattern
to traverse the tree of relational expressions.void
collectVariablesSet(java.util.Set<CorrelationId> variableSet)
Collects variables set by this expression.void
collectVariablesUsed(java.util.Set<CorrelationId> variableSet)
Collects variables known to be used by this expression or its descendants.RelOptCost
computeSelfCost(RelOptPlanner planner)
Deprecated.CallRelMetadataQuery.getNonCumulativeCost(RelNode)
; if you wish to override the default cost formula, override thecomputeSelfCost(RelOptPlanner, RelMetadataQuery)
method.RelOptCost
computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
Returns the cost of this plan (not including children).RelNode
copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
Creates a copy of this relational expression, perhaps changing traits and inputs.double
estimateRowCount(RelMetadataQuery mq)
Returns an estimate of the number of rows this relational expression will return.void
explain(RelWriter pw)
Describes the inputs and attributes of this relational expression.java.util.List<RexNode>
getChildExps()
Deprecated.use #accept(org.apache.calcite.rex.RexShuttle)java.util.List<RelCollation>
getCollationList()
Deprecated.Convention
getConvention()
Return the CallingConvention trait from this RelNode'strait set
.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.RelDataType
getExpectedInputRowType(int ordinalInParent)
Returns the type of the rows expected for an input.RelNode
getInput(int i)
Returns thei
th input relational expression.java.util.List<RelNode>
getInputs()
Returns an array of this relational expression's inputs.RelOptQuery
getQuery()
Deprecated.java.lang.String
getRelTypeName()
Returns the name of this relational expression's class, sans package name, for use in explain.double
getRows()
Deprecated.CallRelMetadataQuery.getRowCount(RelNode)
; if you wish to override the default row count formula, override theestimateRowCount(RelMetadataQuery)
method.RelDataType
getRowType()
Returns the type of the rows returned by this relational expression.RelOptTable
getTable()
If this relational expression represents an access to a table, returns that table, otherwise returns null.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.java.util.Set<java.lang.String>
getVariablesStopped()
Deprecated.boolean
isDistinct()
Deprecated.boolean
isKey(ImmutableBitSet columns)
Deprecated.boolean
isValid(boolean fail)
Deprecated.boolean
isValid(Litmus litmus, RelNode.Context context)
Returns whether this relational expression is valid.<M extends Metadata>
Mmetadata(java.lang.Class<M> metadataClass, RelMetadataQuery mq)
Returns a metadata interface.RelNode
onRegister(RelOptPlanner planner)
Receives notification that this expression is about to be registered.java.lang.String
recomputeDigest()
Computes the digest, assigns it, and returns it.void
register(RelOptPlanner planner)
Registers any special rules specific to this kind of relational expression.void
replaceInput(int ordinalInParent, RelNode p)
Replaces theordinalInParent
th input.-
Methods inherited from interface org.apache.calcite.plan.RelOptNode
getCluster, getDescription, getDigest, getId, getTraitSet
-
-
-
-
Method Detail
-
getChildExps
@Deprecated java.util.List<RexNode> getChildExps()
Deprecated. use #accept(org.apache.calcite.rex.RexShuttle)Returns a list of this relational expression's child expressions. (These are scalar expressions, and so do not include the relational inputs that are returned bygetInputs()
.The caller should treat the list as unmodifiable; typical implementations will return an immutable list. If there are no child expressions, returns an empty list, not
null
.- Returns:
- List of this relational expression's child expressions
- See Also:
accept(org.apache.calcite.rex.RexShuttle)
-
getConvention
Convention getConvention()
Return the CallingConvention trait from this RelNode'strait set
.- Returns:
- this RelNode's CallingConvention
-
getCorrelVariable
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.- Returns:
- Name of correlating variable, or null
-
isDistinct
@Deprecated boolean isDistinct()
Deprecated. UseRelMetadataQuery.areRowsUnique(RelNode)
Returns whether the same value will not come out twice. Default value isfalse
, derived classes should override.- Returns:
- Whether the same value will not come out twice
-
getInput
RelNode getInput(int i)
Returns thei
th input relational expression.- Parameters:
i
- Ordinal of input- Returns:
i
th input
-
getQuery
@Deprecated RelOptQuery getQuery()
Deprecated.Returns the sub-query this relational expression belongs to.- Returns:
- Sub-query
-
getRowType
RelDataType getRowType()
Returns the type of the rows returned by this relational expression.- Specified by:
getRowType
in interfaceRelOptNode
-
getExpectedInputRowType
RelDataType getExpectedInputRowType(int ordinalInParent)
Returns the type of the rows expected for an input. Defaults togetRowType()
.- Parameters:
ordinalInParent
- input's 0-based ordinal with respect to this parent rel- Returns:
- expected row type
-
getInputs
java.util.List<RelNode> getInputs()
Returns an array of this relational expression's inputs. If there are no inputs, returns an empty list, notnull
.- Specified by:
getInputs
in interfaceRelOptNode
- Returns:
- Array of this relational expression's inputs
-
estimateRowCount
double estimateRowCount(RelMetadataQuery mq)
Returns an estimate of the number of rows this relational expression will return.NOTE 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.- Parameters:
mq
- Metadata query- Returns:
- Estimate of the number of rows this relational expression will return
-
getRows
@Deprecated double getRows()
Deprecated. CallRelMetadataQuery.getRowCount(RelNode)
; if you wish to override the default row count formula, override theestimateRowCount(RelMetadataQuery)
method.
-
getVariablesStopped
@Deprecated java.util.Set<java.lang.String> getVariablesStopped()
Deprecated. UsegetVariablesSet()
andCorrelationId.names(Set)
Returns the names of 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.Note:
getVariablesSet()
is equivalent but returnsCorrelationId
rather than their names. It is preferable except for calling old methods that require a set of strings.- Returns:
- Names of variables which are set in this relational expression
-
getVariablesSet
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.Note: only
Correlate
should set variables.- Returns:
- Names of variables which are set in this relational expression
-
collectVariablesUsed
void collectVariablesUsed(java.util.Set<CorrelationId> variableSet)
Collects variables known to be used by this expression or its descendants. By default, no such information is available and must be derived by analyzing sub-expressions, but some optimizer implementations may insert special expressions which remember such information.- Parameters:
variableSet
- receives variables used
-
collectVariablesSet
void collectVariablesSet(java.util.Set<CorrelationId> variableSet)
Collects variables set by this expression. TODO: is this required?- Parameters:
variableSet
- receives variables known to be set by
-
childrenAccept
void childrenAccept(RelVisitor visitor)
Interacts with theRelVisitor
in avisitor pattern
to traverse the tree of relational expressions.- Parameters:
visitor
- Visitor that will traverse the tree of relational expressions
-
computeSelfCost
RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
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.- Parameters:
planner
- Planner for cost calculationmq
- Metadata query- Returns:
- Cost of this plan (not including children)
-
computeSelfCost
@Deprecated RelOptCost computeSelfCost(RelOptPlanner planner)
Deprecated. CallRelMetadataQuery.getNonCumulativeCost(RelNode)
; if you wish to override the default cost formula, override thecomputeSelfCost(RelOptPlanner, RelMetadataQuery)
method.
-
metadata
<M extends Metadata> M metadata(java.lang.Class<M> metadataClass, RelMetadataQuery mq)
Returns a metadata interface.- Type Parameters:
M
- Type of metadata being requested- Parameters:
metadataClass
- Metadata interfacemq
- Metadata query- Returns:
- Metadata object that supplies the desired metadata (never null, although if the information is not present the metadata object may return null from all methods)
-
explain
void explain(RelWriter pw)
Describes the inputs and attributes of this relational expression. Each node should callsuper.explain
, then call theRelWriterImpl.input(String, RelNode)
andRelWriterImpl.item(String, Object)
methods for each input and attribute.- Parameters:
pw
- Plan writer
-
onRegister
RelNode onRegister(RelOptPlanner planner)
Receives notification that this expression is about to be registered. The implementation of this method must at least register all child expressions.- Parameters:
planner
- Planner that plans this relational node- Returns:
- Relational expression that should be used by the planner
-
recomputeDigest
java.lang.String recomputeDigest()
Computes the digest, assigns it, and returns it. For planner use only.- Returns:
- Digest of this relational expression
-
replaceInput
void replaceInput(int ordinalInParent, RelNode p)
Replaces theordinalInParent
th input. You must override this method if you overridegetInputs()
.- Parameters:
ordinalInParent
- Position of the child input, 0 is the firstp
- New node that should be put at positionordinalInParent
-
getTable
RelOptTable getTable()
If this relational expression represents an access to a table, returns that table, otherwise returns null.- Returns:
- If this relational expression represents an access to a table, returns that table, otherwise returns null
-
getRelTypeName
java.lang.String getRelTypeName()
Returns the name of this relational expression's class, sans package name, for use in explain. For example, for aorg.apache.calcite.rel.ArrayRel.ArrayReader
, this method returns "ArrayReader".- Returns:
- Name of this relational expression's class, sans package name, for use in explain
-
isValid
boolean isValid(Litmus litmus, RelNode.Context context)
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.- Parameters:
litmus
- What to do if invalidcontext
- Context for validity checking- Returns:
- Whether relational expression is valid
- Throws:
java.lang.AssertionError
- if this relational expression is invalid and litmus is THROW
-
isValid
@Deprecated boolean isValid(boolean fail)
Deprecated.
-
getCollationList
@Deprecated java.util.List<RelCollation> getCollationList()
Deprecated. UseRelMetadataQuery.distribution(RelNode)
Returns a description of the physical ordering (or orderings) of this relational expression. Never null.- Returns:
- Description of the physical ordering (or orderings) of this relational expression. Never null
-
copy
RelNode copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
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.
- Parameters:
traitSet
- Trait setinputs
- Inputs- Returns:
- Copy of this relational expression, substituting traits and inputs
-
register
void register(RelOptPlanner planner)
Registers any special rules specific to this kind of relational expression.The planner calls this method this first time that it sees a relational expression of this class. The derived class should call
RelOptPlanner.addRule(org.apache.calcite.plan.RelOptRule)
for each rule, and then callsuper.register
.- Parameters:
planner
- Planner to be used to register additional relational expressions
-
isKey
@Deprecated boolean isKey(ImmutableBitSet columns)
Deprecated. UseRelMetadataQuery.areColumnsUnique(RelNode, ImmutableBitSet)
Returns whether the result of this relational expression is uniquely identified by this columns with the given ordinals.For example, if this relational expression is a LogicalTableScan to T(A, B, C, D) whose key is (A, B), then isKey([0, 1]) yields true, and isKey([0]) and isKey([0, 2]) yields false.
- Parameters:
columns
- Ordinals of key columns- Returns:
- Whether the given columns are a key or a superset of a key
-
accept
RelNode accept(RelShuttle shuttle)
Accepts a visit from a shuttle.- Parameters:
shuttle
- Shuttle- Returns:
- A copy of this node incorporating changes made by the shuttle to this node's children
-
accept
RelNode accept(RexShuttle shuttle)
Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created.- Parameters:
shuttle
- Shuttle- Returns:
- A copy of this node incorporating changes made by the shuttle to this node's children
-
-