Expand description
Aggregate executor.
Handles SELECT … <aggs> … [GROUP BY …] queries. The planning strategy
is straightforward:
- Walk the SELECT (and ORDER BY) expressions to find every aggregate
function call. Dedupe by AST equality and assign each
__agg_<i>. - Same for every
GROUP BYexpression: assign__grp_<j>. - Stream the WHERE-filtered rows, group by the tuple of GROUP BY values, and update per-group aggregate state.
- Materialise a synthetic per-group row containing
[__grp_0..__grp_K, __agg_0..__agg_N]and rewrite the user’s SELECT / ORDER BY expressions to reference those synthetic columns instead of the originals. - Evaluate the rewritten expressions against the synthetic schema and emit results.
v1.8 implements count(*), count(expr), sum, min, max, avg.
NULL semantics follow PG: aggregates skip NULL inputs (except
count(*), which counts rows). sum(int) widens to BigInt;
avg(int|bigint) returns Float.
Structs§
- AggResult
- Output of running the aggregate path. Schema describes one row per group; rows are not yet ORDER BY-sorted (caller does it).
Functions§
- contains_
aggregate - is_
aggregate_ name - run
- Execute aggregate logic against an already-WHERE-filtered iterator of
rows.
table_aliasis the alias accepted by column resolution. - uses_
aggregate - True if this statement should go through the aggregate path.