Class Project
- java.lang.Object
-
- org.apache.calcite.rel.AbstractRelNode
-
- org.apache.calcite.rel.SingleRel
-
- org.apache.calcite.rel.core.Project
-
- All Implemented Interfaces:
java.lang.Cloneable
,RelOptNode
,RelNode
- Direct Known Subclasses:
Bindables.BindableProject
,CassandraProject
,ElasticsearchProject
,EnumerableProject
,GeodeProject
,JdbcRules.JdbcProject
,LogicalProject
,MongoProject
,PigProject
public abstract class Project extends SingleRel
Relational expression that computes a set of 'select expressions' from its input relational expression.- See Also:
LogicalProject
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Project.Flags
Deprecated.-
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Project(RelOptCluster cluster, RelTraitSet traits, RelNode input, java.util.List<? extends RexNode> projects, RelDataType rowType)
Creates a Project.protected
Project(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, java.util.List<? extends RexNode> projects, RelDataType rowType, int flags)
Deprecated.protected
Project(RelInput input)
Creates a Project by parsing serialized output.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RelNode
accept(RexShuttle shuttle)
Accepts a visit from a shuttle.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.abstract Project
copy(RelTraitSet traitSet, RelNode input, java.util.List<RexNode> projects, RelDataType rowType)
Copies a project.Project
copy(RelTraitSet traitSet, RelNode input, java.util.List<RexNode> projects, RelDataType rowType, int flags)
Deprecated.RelWriter
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.java.util.List<RexNode>
getChildExps()
Returns a list of this relational expression's child expressions.int
getFlags()
Deprecated.Mappings.TargetMapping
getMapping()
Returns a mapping, or null if this projection is not a mapping.static Mappings.TargetMapping
getMapping(int inputFieldCount, java.util.List<? extends RexNode> projects)
Returns a mapping of a set of project expressions.java.util.List<Pair<RexNode,java.lang.String>>
getNamedProjects()
Returns a list of (expression, name) pairs.static Mappings.TargetMapping
getPartialMapping(int inputFieldCount, java.util.List<? extends RexNode> projects)
Returns a partial mapping of a set of project expressions.Permutation
getPermutation()
Returns a permutation, if this projection is merely a permutation of its input fields; otherwise null.static Permutation
getPermutation(int inputFieldCount, java.util.List<? extends RexNode> projects)
Returns a permutation, if this projection is merely a permutation of its input fields; otherwise null.java.util.List<RexNode>
getProjects()
Returns the project expressions.boolean
isBoxed()
Deprecated.boolean
isMapping()
Checks whether this is a functional mapping.boolean
isValid(Litmus litmus, 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, computeDigest, computeSelfCost, explain, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraitSet, getVariablesSet, getVariablesStopped, isDistinct, isKey, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
-
-
-
-
Field Detail
-
exps
protected final com.google.common.collect.ImmutableList<RexNode> exps
-
-
Constructor Detail
-
Project
protected Project(RelOptCluster cluster, RelTraitSet traits, RelNode input, java.util.List<? extends RexNode> projects, RelDataType rowType)
Creates a Project.- Parameters:
cluster
- Cluster that this relational expression belongs totraits
- Traits of this relational expressioninput
- Input relational expressionprojects
- List of expressions for the input columnsrowType
- Output row type
-
Project
@Deprecated protected Project(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, java.util.List<? extends RexNode> projects, RelDataType rowType, int flags)
Deprecated.
-
Project
protected Project(RelInput input)
Creates a Project by parsing serialized output.
-
-
Method Detail
-
copy
public final RelNode 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 Project copy(RelTraitSet traitSet, RelNode input, java.util.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(RelTraitSet, List)
-
copy
@Deprecated public Project copy(RelTraitSet traitSet, RelNode input, java.util.List<RexNode> projects, RelDataType rowType, int flags)
Deprecated.
-
isBoxed
@Deprecated public boolean isBoxed()
Deprecated.
-
getChildExps
public java.util.List<RexNode> getChildExps()
Description copied from interface:RelNode
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 byRelNode.getInputs()
.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
.- Specified by:
getChildExps
in interfaceRelNode
- Overrides:
getChildExps
in classAbstractRelNode
- Returns:
- List of this relational expression's child expressions
- See Also:
RelNode.accept(org.apache.calcite.rex.RexShuttle)
-
accept
public RelNode accept(RexShuttle shuttle)
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.- 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
public java.util.List<RexNode> getProjects()
Returns the project expressions.- Returns:
- Project expressions
-
getNamedProjects
public final java.util.List<Pair<RexNode,java.lang.String>> getNamedProjects()
Returns a list of (expression, name) pairs. Convenient for various transformations.- Returns:
- List of (expression, name) pairs
-
getFlags
@Deprecated public int getFlags()
Deprecated.
-
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
-
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)
-
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 classSingleRel
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
getMapping
public Mappings.TargetMapping 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 Mappings.TargetMapping getMapping(int inputFieldCount, java.util.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 a source field may appear as zero, one, or more target fields. Thus you can safely call
Mappings.TargetMapping.getTarget(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, java.util.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
public Permutation 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 Permutation getPermutation(int inputFieldCount, java.util.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.
-
-