Expand description
Aggregation functions for query results.
Implements core aggregation operations on Arrow arrays:
count, sum, min, max, avg, first, last.
Supports group-by aggregation partitioned by tag columns.
§Memory model
StreamingAggregator is the form to reach for over a lazy scan: batches
are pushed in and dropped, and the state held is one accumulator set per
group. Peak memory is therefore O(groups × fields) and independent of
how many rows were aggregated — a SELECT avg(x) over a week of 1 s data
produces its single row without ever holding the week.
The whole-slice entry points (aggregate_batch, aggregate_grouped,
aggregate_grouped_streaming) are conveniences for callers that already
hold their input.
The output is still a single RecordBatch, so a group-by over a very
high-cardinality column is bounded by the group count rather than the row
count. Pass a MemoryTracker to fail early
rather than OOM in that case.
Structs§
- Decimal
Track - The exact half of an accumulator, allocated only for decimal columns.
- Streaming
Aggregator - Constant-memory aggregation state that batches are pushed into.
Enums§
- AggFn
- Aggregation function type.
- AggResult
- One aggregate’s result, in the type that keeps it exact.
- Aggregation
Strategy - Aggregation strategy chosen based on estimated group-key cardinality.
- Num
- A value pulled out of a column, in the type that keeps it exact.
Constants§
- AVG_
EXTRA_ SCALE - Extra fractional digits an average of a decimal column is computed to.
Functions§
- agg_
fn_ name - Human-readable function name for column naming.
- agg_
result_ column - Build one output column from a column of results.
- aggregate_
batch - Apply aggregation to a
RecordBatchwithout grouping. - aggregate_
grouped - Apply aggregation with group-by support.
- aggregate_
grouped_ streaming - Streaming group-by aggregation over multiple
RecordBatches. - aggregate_
sorted - Sort-based group-by aggregation.
- choose_
strategy - Choose an aggregation strategy based on estimated cardinality.