public abstract class Aggregate extends SingleRel
It corresponds to the GROUP BY operator in a SQL query
statement, together with the aggregate functions in the SELECT
clause.
Rules:
| Modifier and Type | Class and Description |
|---|---|
static class |
Aggregate.AggCallBinding
Implementation of the
SqlOperatorBinding interface for an
aggregate call applied to a set of operands in the
context of a LogicalAggregate. |
static class |
Aggregate.Group
What kind of roll-up is it?
|
| Modifier and Type | Field and Description |
|---|---|
protected List<AggregateCall> |
aggCalls |
protected ImmutableBitSet |
groupSet |
com.google.common.collect.ImmutableList<ImmutableBitSet> |
groupSets |
boolean |
indicator |
static com.google.common.base.Predicate<Aggregate> |
IS_SIMPLE |
digest, id, rowType, traitSet| Modifier | Constructor and Description |
|---|---|
protected |
Aggregate(RelInput input)
Creates an Aggregate by parsing serialized output.
|
protected |
Aggregate(RelOptCluster cluster,
RelTraitSet traits,
RelNode child,
boolean indicator,
ImmutableBitSet groupSet,
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Creates an Aggregate.
|
| Modifier and Type | Method and Description |
|---|---|
RelOptCost |
computeSelfCost(RelOptPlanner planner)
Returns the cost of this plan (not including children).
|
boolean |
containsDistinctCall()
Returns whether any of the aggregates are DISTINCT.
|
RelNode |
copy(RelTraitSet traitSet,
List<RelNode> inputs)
Creates a copy of this relational expression, perhaps changing traits and
inputs.
|
abstract Aggregate |
copy(RelTraitSet traitSet,
RelNode input,
boolean indicator,
ImmutableBitSet groupSet,
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Creates a copy of this aggregate.
|
protected RelDataType |
deriveRowType() |
static RelDataType |
deriveRowType(RelDataTypeFactory typeFactory,
RelDataType inputRowType,
boolean indicator,
ImmutableBitSet groupSet,
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Computes the row type of an
Aggregate before it exists. |
RelWriter |
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.
|
List<AggregateCall> |
getAggCallList()
Returns a list of calls to aggregate functions.
|
int |
getGroupCount()
Returns the number of grouping fields.
|
ImmutableBitSet |
getGroupSet()
Returns a bit set of the grouping fields.
|
com.google.common.collect.ImmutableList<ImmutableBitSet> |
getGroupSets()
Returns the list of grouping sets computed by this Aggregate.
|
Aggregate.Group |
getGroupType()
Returns the type of roll-up.
|
int |
getIndicatorCount()
Returns the number of indicator fields.
|
double |
getRows()
Returns an estimate of the number of rows this relational expression will
return.
|
boolean |
isDistinct()
Returns whether the same value will not come out twice.
|
childrenAccept, getInput, getInputs, replaceInputaccept, accept, collectVariablesSet, collectVariablesUsed, computeDigest, explain, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRowType, getTable, getTraitSet, getVariablesStopped, isKey, isValid, metadata, onRegister, recomputeDigest, register, sole, toStringpublic static final com.google.common.base.Predicate<Aggregate> IS_SIMPLE
Bug.CALCITE_461_FIXEDpublic final boolean indicator
protected final List<AggregateCall> aggCalls
protected final ImmutableBitSet groupSet
public final com.google.common.collect.ImmutableList<ImmutableBitSet> groupSets
protected Aggregate(RelOptCluster cluster, RelTraitSet traits, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
All members of groupSets must be sub-sets of groupSet.
For a simple GROUP BY, groupSets is a singleton list
containing groupSet.
If GROUP BY is not specified,
or equivalently if GROUP BY () is specified,
groupSet will be the empty set,
and groupSets will have one element, that empty set.
If CUBE, ROLLUP or GROUPING SETS are
specified, groupSets will have additional elements,
but they must each be a subset of groupSet,
and they must be sorted by inclusion:
(0, 1, 2), (1), (0, 2), (0), ().
cluster - Clustertraits - Traitschild - Childindicator - Whether row type should include indicator fields to
indicate which grouping set is active; must be true if
aggregate is not simplegroupSet - Bit set of grouping fieldsgroupSets - List of all grouping sets; null for just groupSetaggCalls - Collection of calls to aggregate functionsprotected Aggregate(RelInput input)
public final RelNode copy(RelTraitSet traitSet, List<RelNode> inputs)
RelNodeSub-classes with other important attributes are encouraged to create variants of this method with more parameters.
copy in interface RelNodecopy in class AbstractRelNodetraitSet - Trait setinputs - Inputspublic abstract Aggregate copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
traitSet - Traitsinput - Inputindicator - Whether row type should include indicator fields to
indicate which grouping set is active; must be true if
aggregate is not simplegroupSet - Bit set of grouping fieldsgroupSets - List of all grouping sets; null for just groupSetaggCalls - Collection of calls to aggregate functionsAggregate if any parameter differs from the value of
this Aggregate, or just this if all the parameters are
the samecopy(org.apache.calcite.plan.RelTraitSet, java.util.List)public boolean isDistinct()
RelNodefalse, derived classes should override.isDistinct in interface RelNodeisDistinct in class AbstractRelNodepublic List<AggregateCall> getAggCallList()
public int getGroupCount()
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.
public int getIndicatorCount()
This is the same as getGroupCount() if indicator is
true, zero if indicator is false.
The offset of the first aggregate call in the output record is always groupCount + indicatorCount.
public ImmutableBitSet getGroupSet()
public com.google.common.collect.ImmutableList<ImmutableBitSet> getGroupSets()
groupSetpublic RelWriter explainTerms(RelWriter pw)
AbstractRelNodesuper.explainTerms, then call the
RelWriterImpl.input(String, RelNode)
and
RelWriterImpl.item(String, Object)
methods for each input and attribute.explainTerms in class SingleRelpw - Plan writerpublic double getRows()
RelNodeNOTE 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.
public RelOptCost computeSelfCost(RelOptPlanner planner)
RelNodeNOTE 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.
computeSelfCost in interface RelNodecomputeSelfCost in class AbstractRelNodeplanner - Planner for cost calculationprotected RelDataType deriveRowType()
deriveRowType in class SingleRelpublic static RelDataType deriveRowType(RelDataTypeFactory typeFactory, RelDataType inputRowType, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
Aggregate before it exists.typeFactory - Type factoryinputRowType - Input row typeindicator - Whether row type should include indicator fields to
indicate which grouping set is active; must be true if
aggregate is not simplegroupSet - Bit set of grouping fieldsgroupSets - List of all grouping sets; null for just groupSetaggCalls - Collection of calls to aggregate functionspublic boolean containsDistinctCall()
public Aggregate.Group getGroupType()
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.