Class Aggregate
- All Implemented Interfaces:
Cloneable,RelOptNode,Hintable,RelNode
- Direct Known Subclasses:
Bindables.BindableAggregate,ElasticsearchAggregate,EnumerableAggregateBase,GeodeAggregate,JdbcRules.JdbcAggregate,LogicalAggregate,MongoAggregate,PigAggregate
It corresponds to the GROUP BY operator in a SQL query
statement, together with the aggregate functions in the SELECT
clause.
Rules:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplementation of theSqlOperatorBindinginterface for anaggregate callapplied to a set of operands in the context of aLogicalAggregate.static enumDescribes the kind of roll-up.static classUsed for PERCENTILE_DISC return type inference.Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<AggregateCall>protected final ImmutableBitSetfinal com.google.common.collect.ImmutableList<ImmutableBitSet>protected final com.google.common.collect.ImmutableList<RelHint>final booleanDeprecated.static final com.google.common.base.Predicate<Aggregate>Deprecated.static final com.google.common.base.Predicate<Aggregate>Deprecated.static final com.google.common.base.Predicate<Aggregate>Deprecated.Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAggregate(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelNode input, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Creates an Aggregate.protectedAggregate(RelOptCluster cluster, RelTraitSet traits, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Deprecated.protectedAggregate(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Deprecated.protectedCreates an Aggregate by parsing serialized output. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckIndicator(boolean indicator) Used internally; will removed whenindicatoris removed, before 2.0.@Nullable RelOptCostcomputeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) Returns the cost of this plan (not including children).booleanReturns whether any of the aggregates are DISTINCT.final RelNodecopy(RelTraitSet traitSet, List<RelNode> inputs) Creates a copy of this relational expression, perhaps changing traits and inputs.copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Deprecated.abstract Aggregatecopy(RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Creates a copy of this aggregate.protected RelDataTypestatic RelDataTypederiveRowType(RelDataTypeFactory typeFactory, RelDataType inputRowType, boolean indicator, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Computes the row type of anAggregatebefore it exists.doubleReturns an estimate of the number of rows this relational expression will return.Describes the inputs and attributes of this relational expression.Returns a list of calls to aggregate functions.intReturns the number of grouping fields.Returns a bit set of the grouping fields.com.google.common.collect.ImmutableList<ImmutableBitSet>Returns the list of grouping sets computed by this Aggregate.Returns the type of roll-up.com.google.common.collect.ImmutableList<RelHint>getHints()Returns the hints of this relational expressions as an immutable list.intDeprecated.Returns a list of calls to aggregate functions together with their output field names.static booleanisNotGrandTotal(Aggregate aggregate) static booleanbooleanisValid(Litmus litmus, @Nullable RelNode.Context context) Returns whether this relational expression is valid.static booleannoIndicator(Aggregate aggregate) Deprecated.Methods inherited from class org.apache.calcite.rel.SingleRel
childrenAccept, getInput, getInputs, replaceInputMethods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, accept, collectVariablesSet, collectVariablesUsed, deepEquals, deepHashCode, equals, explain, getCluster, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getRelDigest, getRelTypeName, getRowType, getTable, getTraitSet, getVariablesSet, hashCode, isEnforcer, metadata, onRegister, recomputeDigest, register, sole, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.calcite.rel.hint.Hintable
attachHints, withHintsMethods inherited from interface org.apache.calcite.rel.RelNode
explain, fieldIsNullable, stripped
-
Field Details
-
hints
-
IS_SIMPLE
Deprecated. -
NO_INDICATOR
Deprecated. -
IS_NOT_GRAND_TOTAL
Deprecated. -
indicator
Deprecated.- See Also:
-
aggCalls
-
groupSet
-
groupSets
-
-
Constructor Details
-
Aggregate
protected Aggregate(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelNode input, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Creates an Aggregate.All members of
groupSetsmust be sub-sets ofgroupSet. For a simpleGROUP BY,groupSetsis a singleton list containinggroupSet.It is allowed for
groupSetto contain bits that are not in any of thegroupSets, even this does not correspond to valid SQL. See discussion inRelBuilder.groupKey(ImmutableBitSet, Iterable).If
GROUP BYis not specified, or equivalently ifGROUP BY ()is specified,groupSetwill be the empty set, andgroupSetswill have one element, that empty set.If
CUBE,ROLLUPorGROUPING SETSare specified,groupSetswill have additional elements, but they must each be a subset ofgroupSet, and they must be sorted by inclusion:(0, 1, 2), (1), (0, 2), (0), ().- Parameters:
cluster- ClustertraitSet- Trait sethints- Hints of this relational expressioninput- Input relational expressiongroupSet- Bit set of grouping fieldsgroupSets- List of all grouping sets; null for justgroupSetaggCalls- Collection of calls to aggregate functions
-
Aggregate
@Deprecated protected Aggregate(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Deprecated. -
Aggregate
@Deprecated protected Aggregate(RelOptCluster cluster, RelTraitSet traits, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Deprecated. -
Aggregate
Creates an Aggregate by parsing serialized output.
-
-
Method Details
-
isSimple
-
checkIndicator
public static void checkIndicator(boolean indicator) Used internally; will removed whenindicatoris removed, before 2.0. -
isNotGrandTotal
-
noIndicator
Deprecated. -
copy
Description copied from interface:RelNodeCreates 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:
copyin interfaceRelNode- Overrides:
copyin classAbstractRelNode- Parameters:
traitSet- Trait setinputs- Inputs- Returns:
- Copy of this relational expression, substituting traits and inputs
-
copy
public abstract Aggregate copy(RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Creates a copy of this aggregate.- Parameters:
traitSet- Traitsinput- InputgroupSet- Bit set of grouping fieldsgroupSets- List of all grouping sets; null for justgroupSetaggCalls- Collection of calls to aggregate functions- Returns:
- New
Aggregateif any parameter differs from the value of thisAggregate, or justthisif all the parameters are the same - See Also:
-
copy
@Deprecated public Aggregate copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Deprecated. -
getAggCallList
Returns a list of calls to aggregate functions.- Returns:
- list of calls to aggregate functions
-
getNamedAggCalls
Returns a list of calls to aggregate functions together with their output field names.- Returns:
- list of calls to aggregate functions and their output field names
-
getGroupCount
public int getGroupCount()Returns the number of grouping fields. These grouping fields are the leading fields in both the input and output records.NOTE: The
getGroupSet()data structure allows for the grouping fields to not be on the leading edge. New code should, if possible, assume that grouping fields are in arbitrary positions in the input relational expression.- Returns:
- number of grouping fields
-
getIndicatorCount
Deprecated.Returns the number of indicator fields.Always zero.
- Returns:
- number of indicator fields, always zero
-
getGroupSet
Returns a bit set of the grouping fields.- Returns:
- bit set of ordinals of grouping fields
-
getGroupSets
Returns the list of grouping sets computed by this Aggregate.- Returns:
- List of all grouping sets
-
explainTerms
Description copied from class:AbstractRelNodeDescribes 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:
explainTermsin classSingleRel- Parameters:
pw- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
estimateRowCount
Description copied from interface:RelNodeReturns 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.- Specified by:
estimateRowCountin interfaceRelNode- Overrides:
estimateRowCountin classSingleRel- Parameters:
mq- Metadata query- Returns:
- Estimate of the number of rows this relational expression will return
-
computeSelfCost
Description copied from interface:RelNodeReturns 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:
computeSelfCostin interfaceRelNode- Overrides:
computeSelfCostin classAbstractRelNode- Parameters:
planner- Planner for cost calculationmq- Metadata query- Returns:
- Cost of this plan (not including children)
-
deriveRowType
- Overrides:
deriveRowTypein classSingleRel
-
deriveRowType
public static RelDataType deriveRowType(RelDataTypeFactory typeFactory, RelDataType inputRowType, boolean indicator, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) Computes the row type of anAggregatebefore it exists.- Parameters:
typeFactory- Type factoryinputRowType- Input row typeindicator- Deprecated, always falsegroupSet- Bit set of grouping fieldsgroupSets- List of all grouping sets; null for justgroupSetaggCalls- Collection of calls to aggregate functions- Returns:
- Row type of the aggregate
-
isValid
Description copied from interface:RelNodeReturns 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
AssertionErrorif it is not valid.- Specified by:
isValidin interfaceRelNode- Overrides:
isValidin classAbstractRelNode- Parameters:
litmus- What to do if invalidcontext- Context for validity checking- Returns:
- Whether relational expression is valid
-
containsDistinctCall
public boolean containsDistinctCall()Returns whether any of the aggregates are DISTINCT.- Returns:
- Whether any of the aggregates are DISTINCT
-
getHints
Description copied from interface:HintableReturns the hints of this relational expressions as an immutable list. -
getGroupType
Returns the type of roll-up.- Returns:
- Type of roll-up
-