public static class SqlSplittableAggFunction.CountSplitter extends Object implements SqlSplittableAggFunction
COUNT.
COUNT splits into itself followed by SUM. (Actually SUM0, because the total needs to be 0, not null, if there are 0 rows.) This rule works for any number of arguments to COUNT, including COUNT(*).
SqlSplittableAggFunction.AbstractSumSplitter, SqlSplittableAggFunction.CountSplitter, SqlSplittableAggFunction.Registry<E>, SqlSplittableAggFunction.SelfSplitter, SqlSplittableAggFunction.Sum0Splitter, SqlSplittableAggFunction.SumSplitter| Modifier and Type | Field and Description |
|---|---|
static SqlSplittableAggFunction.CountSplitter |
INSTANCE |
| Constructor and Description |
|---|
CountSplitter() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public static final SqlSplittableAggFunction.CountSplitter INSTANCE
public AggregateCall split(AggregateCall aggregateCall, Mappings.TargetMapping mapping)
split in interface SqlSplittableAggFunctionpublic AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e)
SqlSplittableAggFunctionother in interface SqlSplittableAggFunctionpublic AggregateCall topSplit(RexBuilder rexBuilder, SqlSplittableAggFunction.Registry<RexNode> extra, int offset, RelDataType inputRowType, AggregateCall aggregateCall, int leftSubTotal, int rightSubTotal)
SqlSplittableAggFunctionMost implementations will add a single aggregate call to
aggCalls, and return a RexInputRef that points to it.
topSplit in interface SqlSplittableAggFunctionrexBuilder - 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-totalpublic RexNode 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
COUNT(*), and COUNT applied to all NOT NULL arguments,
become 1; otherwise
CASE WHEN arg0 IS NOT NULL THEN 1 ELSE 0 END.
singleton in interface SqlSplittableAggFunctionrexBuilder - Rex builderinputRowType - Input row typeaggregateCall - Aggregate callCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.