Class Project
- All Implemented Interfaces:
Cloneable
,RelOptNode
,Hintable
,RelNode
- Direct Known Subclasses:
Bindables.BindableProject
,CassandraProject
,ElasticsearchProject
,EnumerableProject
,GeodeProject
,InnodbProject
,JdbcRules.JdbcProject
,LogicalProject
,MongoProject
,PigProject
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
Field Summary
Modifier and TypeFieldDescriptionprotected final com.google.common.collect.ImmutableList<RexNode>
protected final com.google.common.collect.ImmutableList<RelHint>
protected final com.google.common.collect.ImmutableSet<CorrelationId>
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet
-
Constructor Summary
ModifierConstructorDescriptionprotected
Project
(RelOptCluster cluster, RelTraitSet traits, List<RelHint> hints, RelNode input, List<? extends RexNode> projects, RelDataType rowType) Deprecated.protected
Project
(RelOptCluster cluster, RelTraitSet traits, List<RelHint> hints, RelNode input, List<? extends RexNode> projects, RelDataType rowType, Set<CorrelationId> variableSet) Creates a Project.protected
Project
(RelOptCluster cluster, RelTraitSet traits, RelNode input, List<? extends RexNode> projects, RelDataType rowType) Deprecated.protected
Project
(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, List<? extends RexNode> projects, RelDataType rowType, int flags) Deprecated.protected
Creates a Project by parsing serialized output. -
Method Summary
Modifier and TypeMethodDescriptionaccept
(RexShuttle shuttle) Accepts a visit from a shuttle.@Nullable RelOptCost
computeSelfCost
(RelOptPlanner planner, RelMetadataQuery mq) Returns the cost of this plan (not including children).final boolean
Returns whether this Project contains any windowed-aggregate functions.final RelNode
copy
(RelTraitSet traitSet, List<RelNode> inputs) Creates a copy of this relational expression, perhaps changing traits and inputs.abstract Project
copy
(RelTraitSet traitSet, RelNode input, List<RexNode> projects, RelDataType rowType) Copies a project.copy
(RelTraitSet traitSet, RelNode input, List<RexNode> projects, RelDataType rowType, int flags) Deprecated.protected boolean
deepEquals0
(@Nullable Object obj) protected int
Describes the inputs and attributes of this relational expression.Returns a list of project expressions, each of which is wrapped in a call toAS
if its field name differs from the default.int
getFlags()
Deprecated.com.google.common.collect.ImmutableList<RelHint>
getHints()
Returns the hints of this relational expressions as an immutable list.@Nullable Mappings.TargetMapping
Returns a mapping, or null if this projection is not a mapping.static @Nullable Mappings.TargetMapping
getMapping
(int inputFieldCount, List<? extends RexNode> projects) Returns a mapping of a set of project expressions.Returns a list of (expression, name) pairs.static Mappings.TargetMapping
getPartialMapping
(int inputFieldCount, List<? extends RexNode> projects) Returns a partial mapping of a set of project expressions.@Nullable Permutation
Returns a permutation, if this projection is merely a permutation of its input fields; otherwise null.static @Nullable Permutation
getPermutation
(int inputFieldCount, List<? extends RexNode> projects) Returns a permutation, if this projection is merely a permutation of its input fields; otherwise null.Returns the project expressions.Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.boolean
isBoxed()
Deprecated.boolean
Checks whether this is a functional mapping.boolean
isValid
(Litmus litmus, @Nullable RelNode.Context context) Returns whether this relational expression is valid.Methods inherited from class org.apache.calcite.rel.SingleRel
childrenAccept, deriveRowType, estimateRowCount, getInput, getInputs, replaceInput
Methods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, collectVariablesSet, collectVariablesUsed, deepEquals, deepHashCode, equals, explain, getCluster, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getRelDigest, getRelTypeName, getRowType, getTable, getTraitSet, hashCode, isEnforcer, metadata, onRegister, recomputeDigest, register, sole, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.calcite.rel.hint.Hintable
attachHints, withHints
Methods inherited from interface org.apache.calcite.rel.RelNode
explain, fieldIsNullable, stripped
-
Field Details
-
exps
-
hints
-
variablesSet
-
-
Constructor Details
-
Project
protected Project(RelOptCluster cluster, RelTraitSet traits, List<RelHint> hints, RelNode input, List<? extends RexNode> projects, RelDataType rowType, Set<CorrelationId> variableSet) Creates a Project.- Parameters:
cluster
- Cluster that this relational expression belongs totraits
- Traits of this relational expressionhints
- Hints of this relation expressioninput
- Input relational expressionprojects
- List of expressions for the input columnsrowType
- Output row typevariableSet
- Correlation variables set by this relational expression to be used by nested expressions
-
Project
@Deprecated protected Project(RelOptCluster cluster, RelTraitSet traits, List<RelHint> hints, RelNode input, List<? extends RexNode> projects, RelDataType rowType) Deprecated. -
Project
@Deprecated protected Project(RelOptCluster cluster, RelTraitSet traits, RelNode input, List<? extends RexNode> projects, RelDataType rowType) Deprecated. -
Project
@Deprecated protected Project(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, List<? extends RexNode> projects, RelDataType rowType, int flags) Deprecated. -
Project
Creates a Project by parsing serialized output.
-
-
Method Details
-
copy
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 Project copy(RelTraitSet traitSet, RelNode input, List<RexNode> projects, RelDataType rowType) Copies a project.- Parameters:
traitSet
- Traitsinput
- Inputprojects
- Project expressionsrowType
- Output row type- Returns:
- New
Project
if any parameter differs from the value of thisProject
, or justthis
if all the parameters are the same - See Also:
-
copy
@Deprecated public Project copy(RelTraitSet traitSet, RelNode input, List<RexNode> projects, RelDataType rowType, int flags) Deprecated. -
isBoxed
Deprecated. -
accept
Description copied from interface:RelNode
Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created. This new relation might have a different row-type.- Specified by:
accept
in interfaceRelNode
- Overrides:
accept
in classAbstractRelNode
- Parameters:
shuttle
- Shuttle- Returns:
- A copy of this node incorporating changes made by the shuttle to this node's children
-
getProjects
Returns the project expressions.- Returns:
- Project expressions
-
getNamedProjects
Returns a list of (expression, name) pairs. Convenient for various transformations.- Returns:
- List of (expression, name) pairs
-
getAliasedProjects
Returns a list of project expressions, each of which is wrapped in a call toAS
if its field name differs from the default.This method has a similar effect to
getNamedProjects()
, but the single list is easier to manage.- See Also:
-
getHints
Description copied from interface:Hintable
Returns the hints of this relational expressions as an immutable list. -
getFlags
Deprecated. -
containsOver
public final boolean containsOver()Returns whether this Project contains any windowed-aggregate functions. -
isValid
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
-
computeSelfCost
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)
-
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.- Specified by:
getVariablesSet
in interfaceRelNode
- Overrides:
getVariablesSet
in classAbstractRelNode
- Returns:
- Names of variables which are set in this relational expression
-
explainTerms
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriter.input(String, RelNode)
andRelWriter.item(String, Object)
methods for each input and attribute.- Overrides:
explainTerms
in classSingleRel
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
deepEquals0
@API(since="1.24", status=INTERNAL) @EnsuresNonNullIf(expression="#1", result=true) protected boolean deepEquals0(@Nullable Object obj) -
deepHashCode0
@API(since="1.24", status=INTERNAL) protected int deepHashCode0() -
getMapping
Returns a mapping, or null if this projection is not a mapping.- Returns:
- Mapping, or null if this projection is not a mapping
-
getMapping
public static @Nullable Mappings.TargetMapping getMapping(int inputFieldCount, List<? extends RexNode> projects) Returns a mapping of a set of project expressions.The mapping is an inverse surjection. Every target has a source field, but no source has more than one target. Thus you can safely call
Mappings.TargetMapping.getSourceOpt(int)
.- Parameters:
inputFieldCount
- Number of input fieldsprojects
- Project expressions- Returns:
- Mapping of a set of project expressions, or null if projection is not a mapping
-
getPartialMapping
public static Mappings.TargetMapping getPartialMapping(int inputFieldCount, List<? extends RexNode> projects) Returns a partial mapping of a set of project expressions.The mapping is an inverse function. Every target has a source field, but a source might have 0, 1 or more targets. Project expressions that do not consist of a mapping are ignored.
- Parameters:
inputFieldCount
- Number of input fieldsprojects
- Project expressions- Returns:
- Mapping of a set of project expressions, never null
-
getPermutation
Returns a permutation, if this projection is merely a permutation of its input fields; otherwise null.- Returns:
- Permutation, if this projection is merely a permutation of its input fields; otherwise null
-
getPermutation
public static @Nullable Permutation getPermutation(int inputFieldCount, List<? extends RexNode> projects) Returns a permutation, if this projection is merely a permutation of its input fields; otherwise null. -
isMapping
public boolean isMapping()Checks whether this is a functional mapping. Every output is a source field, but a source field may appear as zero, one, or more output fields.
-