Package org.apache.calcite.sql
Interface SqlSplittableAggFunction
- All Superinterfaces:
SqlSingletonAggFunction
- All Known Implementing Classes:
SqlSplittableAggFunction.AbstractSumSplitter
,SqlSplittableAggFunction.CountSplitter
,SqlSplittableAggFunction.SelfSplitter
,SqlSplittableAggFunction.Sum0Splitter
,SqlSplittableAggFunction.SumSplitter
Aggregate function that can be split into partial aggregates.
For example, COUNT(x)
can be split into COUNT(x)
on
subsets followed by SUM
to combine those counts.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Common splitting strategy forSUM
andSUM0
functions.static class
Splitting strategy forCOUNT
.static interface
Collection in which one can register an element.static class
Aggregate function that splits into two applications of itself.static class
Splitting strategy forSUM0
function.static class
Splitting strategy forSUM
function. -
Method Summary
Modifier and TypeMethodDescription@Nullable AggregateCall
merge
(AggregateCall top, AggregateCall bottom) Merge top and bottom aggregate calls into a single aggregate call, if they are legit to merge.@Nullable AggregateCall
other
(RelDataTypeFactory typeFactory, AggregateCall e) Called to generate an aggregate for the other side of the join than the side aggregate call's arguments come from.split
(AggregateCall aggregateCall, Mappings.TargetMapping mapping) topSplit
(RexBuilder rexBuilder, SqlSplittableAggFunction.Registry<RexNode> extra, int offset, RelDataType inputRowType, AggregateCall aggregateCall, int leftSubTotal, int rightSubTotal) Generates an aggregate call to merge sub-totals.Methods inherited from interface org.apache.calcite.sql.SqlSingletonAggFunction
singleton
-
Method Details
-
split
-
other
Called to generate an aggregate for the other side of the join than the side aggregate call's arguments come from. Returns null if no aggregate is required. -
topSplit
AggregateCall topSplit(RexBuilder rexBuilder, SqlSplittableAggFunction.Registry<RexNode> extra, int offset, RelDataType inputRowType, AggregateCall aggregateCall, int leftSubTotal, int rightSubTotal) Generates an aggregate call to merge sub-totals.Most implementations will add a single aggregate call to
aggCalls
, and return aRexInputRef
that points to it.- Parameters:
rexBuilder
- Rex builderextra
- Place to define extra input expressionsoffset
- Offset due to grouping columns (and indicator columns if applicable)inputRowType
- Input row typeaggregateCall
- Source aggregate callleftSubTotal
- Ordinal of the sub-total coming from the left side of the join, or -1 if there is no such sub-totalrightSubTotal
- Ordinal of the sub-total coming from the right side of the join, or -1 if there is no such sub-total- Returns:
- Aggregate call
-
merge
Merge top and bottom aggregate calls into a single aggregate call, if they are legit to merge.SUM of SUM becomes SUM; SUM of COUNT becomes COUNT; MAX of MAX becomes MAX; MIN of MIN becomes MIN. AVG of AVG would not match, nor would COUNT of COUNT.
- Parameters:
top
- top aggregate callbottom
- bottom aggregate call- Returns:
- Merged aggregate call, null if fails to merge aggregate calls
-