public abstract class Aggregate extends SingleRel implements Hintable
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
Describes the kind of roll-up.
|
RelNode.Context| Modifier and Type | Field and Description |
|---|---|
protected List<AggregateCall> |
aggCalls |
protected ImmutableBitSet |
groupSet |
com.google.common.collect.ImmutableList<ImmutableBitSet> |
groupSets |
protected com.google.common.collect.ImmutableList<RelHint> |
hints |
boolean |
indicator
Deprecated.
|
static com.google.common.base.Predicate<Aggregate> |
IS_NOT_GRAND_TOTAL
Deprecated.
|
static com.google.common.base.Predicate<Aggregate> |
IS_SIMPLE
Deprecated.
|
static com.google.common.base.Predicate<Aggregate> |
NO_INDICATOR
Deprecated.
|
digest, id, rowType, traitSet| Modifier | Constructor and Description |
|---|---|
protected |
Aggregate(RelInput input)
Creates an Aggregate by parsing serialized output.
|
protected |
Aggregate(RelOptCluster cluster,
RelTraitSet traitSet,
List<RelHint> hints,
RelNode input,
ImmutableBitSet groupSet,
@Nullable List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Creates an Aggregate.
|
protected |
Aggregate(RelOptCluster cluster,
RelTraitSet traits,
RelNode child,
boolean indicator,
ImmutableBitSet groupSet,
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Deprecated.
|
protected |
Aggregate(RelOptCluster cluster,
RelTraitSet traitSet,
RelNode input,
ImmutableBitSet groupSet,
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkIndicator(boolean indicator)
Used internally; will removed when
indicator is removed,
before 2.0. |
@Nullable RelOptCost |
computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq)
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.
|
Aggregate |
copy(RelTraitSet traitSet,
RelNode input,
boolean indicator,
ImmutableBitSet groupSet,
List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Deprecated.
|
abstract Aggregate |
copy(RelTraitSet traitSet,
RelNode input,
ImmutableBitSet groupSet,
@Nullable 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,
@Nullable List<ImmutableBitSet> groupSets,
List<AggregateCall> aggCalls)
Computes the row type of an
Aggregate before it exists. |
double |
estimateRowCount(RelMetadataQuery mq)
Returns an estimate of the number of rows this relational expression will
return.
|
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.
|
com.google.common.collect.ImmutableList<RelHint> |
getHints()
Returns the hints of this relational expressions as an immutable list.
|
int |
getIndicatorCount()
Deprecated.
|
List<Pair<AggregateCall,String>> |
getNamedAggCalls()
Returns a list of calls to aggregate functions together with their output
field names.
|
static boolean |
isNotGrandTotal(Aggregate aggregate) |
static boolean |
isSimple(Aggregate aggregate) |
boolean |
isValid(Litmus litmus,
@Nullable RelNode.Context context)
Returns whether this relational expression is valid.
|
static boolean |
noIndicator(Aggregate aggregate)
Deprecated.
|
childrenAccept, getInput, getInputs, replaceInputaccept, 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, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitattachHints, withHintsexplain, fieldIsNullableprotected final com.google.common.collect.ImmutableList<RelHint> hints
@Deprecated public static final com.google.common.base.Predicate<Aggregate> IS_SIMPLE
@Deprecated public static final com.google.common.base.Predicate<Aggregate> NO_INDICATOR
@Deprecated public static final com.google.common.base.Predicate<Aggregate> IS_NOT_GRAND_TOTAL
@Deprecated public 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 traitSet, List<RelHint> hints, RelNode input, ImmutableBitSet groupSet, @Nullable 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.
It is allowed for groupSet to contain bits that are not in any
of the groupSets, even this does not correspond to valid SQL. See
discussion in
RelBuilder.groupKey(ImmutableBitSet, Iterable).
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 - ClustertraitSet - Trait sethints - Hints of this relational expressioninput - Input relational expressiongroupSet - Bit set of grouping fieldsgroupSets - List of all grouping sets; null for just groupSetaggCalls - Collection of calls to aggregate functions@Deprecated protected Aggregate(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
@Deprecated protected Aggregate(RelOptCluster cluster, RelTraitSet traits, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
protected Aggregate(RelInput input)
public static boolean isSimple(Aggregate aggregate)
public static void checkIndicator(boolean indicator)
indicator is removed,
before 2.0.public static boolean isNotGrandTotal(Aggregate aggregate)
@Deprecated public static boolean noIndicator(Aggregate aggregate)
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, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
traitSet - Traitsinput - InputgroupSet - 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)@Deprecated public Aggregate copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
public List<AggregateCall> getAggCallList()
public List<Pair<AggregateCall,String>> getNamedAggCalls()
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.
@Deprecated public int getIndicatorCount()
Always zero.
public ImmutableBitSet getGroupSet()
public com.google.common.collect.ImmutableList<ImmutableBitSet> getGroupSets()
public RelWriter explainTerms(RelWriter pw)
AbstractRelNodesuper.explainTerms, then call the
RelWriter.input(String, RelNode)
and
RelWriter.item(String, Object)
methods for each input and attribute.explainTerms in class SingleRelpw - Plan writerpublic double estimateRowCount(RelMetadataQuery mq)
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.
estimateRowCount in interface RelNodeestimateRowCount in class SingleRelmq - Metadata querypublic @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
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 calculationmq - Metadata queryprotected RelDataType deriveRowType()
deriveRowType in class SingleRelpublic static RelDataType deriveRowType(RelDataTypeFactory typeFactory, RelDataType inputRowType, boolean indicator, ImmutableBitSet groupSet, @Nullable List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls)
Aggregate before it exists.typeFactory - Type factoryinputRowType - Input row typeindicator - Deprecated, always falsegroupSet - Bit set of grouping fieldsgroupSets - List of all grouping sets; null for just groupSetaggCalls - Collection of calls to aggregate functionspublic boolean isValid(Litmus litmus, @Nullable RelNode.Context context)
RelNodeIf 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.
isValid in interface RelNodeisValid in class AbstractRelNodelitmus - What to do if invalidcontext - Context for validity checkingpublic boolean containsDistinctCall()
public com.google.common.collect.ImmutableList<RelHint> getHints()
Hintablepublic Aggregate.Group getGroupType()
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.