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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classCommon splitting strategy forSUMandSUM0functions.static classSplitting strategy forCOUNT.static interfaceCollection in which one can register an element.static classAggregate function that splits into two applications of itself.static classSplitting strategy forSUM0function.static classSplitting strategy forSUMfunction. -
Method Summary
Modifier and TypeMethodDescription@Nullable AggregateCallmerge(AggregateCall top, AggregateCall bottom) Merge top and bottom aggregate calls into a single aggregate call, if they are legit to merge.@Nullable AggregateCallother(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 aRexInputRefthat 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
-