public interface SqlSplittableAggFunction
For example, COUNT(x) can be split into COUNT(x) on
subsets followed by SUM to combine those counts.
| Modifier and Type | Interface and Description |
|---|---|
static class |
SqlSplittableAggFunction.AbstractSumSplitter
Common splitting strategy for
SUM and SUM0 functions. |
static class |
SqlSplittableAggFunction.CountSplitter
Splitting strategy for
COUNT. |
static interface |
SqlSplittableAggFunction.Registry<E>
Collection in which one can register an element.
|
static class |
SqlSplittableAggFunction.SelfSplitter
Aggregate function that splits into two applications of itself.
|
static class |
SqlSplittableAggFunction.Sum0Splitter
Splitting strategy for
SUM0 function. |
static class |
SqlSplittableAggFunction.SumSplitter
Splitting strategy for
SUM function. |
| Modifier and Type | Method and Description |
|---|---|
@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.
|
RexNode |
singleton(RexBuilder rexBuilder,
RelDataType inputRowType,
AggregateCall aggregateCall)
Generates an expression for the value of the aggregate function when
applied to a single row.
|
AggregateCall |
split(AggregateCall aggregateCall,
Mappings.TargetMapping mapping) |
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.
|
AggregateCall split(AggregateCall aggregateCall, Mappings.TargetMapping mapping)
@Nullable AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e)
AggregateCall topSplit(RexBuilder rexBuilder, SqlSplittableAggFunction.Registry<RexNode> extra, int offset, RelDataType inputRowType, AggregateCall aggregateCall, int leftSubTotal, int rightSubTotal)
Most implementations will add a single aggregate call to
aggCalls, and return a RexInputRef that points to it.
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-totalRexNode singleton(RexBuilder rexBuilder, RelDataType inputRowType, AggregateCall aggregateCall)
For example, if there is one row:
SUM(x) is x
MIN(x) is x
MAX(x) is x
COUNT(x) is CASE WHEN x IS NOT NULL THEN 1 ELSE 0 END 1
which can be simplified to 1 if x is never null
COUNT(*) is 1
rexBuilder - Rex builderinputRowType - Input row typeaggregateCall - Aggregate call@Nullable AggregateCall merge(AggregateCall top, AggregateCall bottom)
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.
top - top aggregate callbottom - bottom aggregate callCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.