Skip to main content

Module aggregate

Module aggregate 

Source
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§

DecimalTrack
The exact half of an accumulator, allocated only for decimal columns.
StreamingAggregator
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.
AggregationStrategy
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 RecordBatch without 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.