Skip to main content

Module agg_naming

Module agg_naming 

Source
Expand description

Canonical output names for aggregate expressions.

One aggregate has two names: the canonical key it is computed and stored under in a finalized group row (sum(amount)), and the user alias the client sees (SELECT SUM(amount) AS total). The rename to the user alias happens last, after HAVING has filtered, so anything that has to address an aggregate mid-pipeline must use the canonical key. Deriving that key in one place keeps the planner’s HAVING rewrite and the physical spec builder from drifting into two different names for the same column.

Functions§

aggregate_field_name
The field name an aggregate accumulates over: the bare column when the argument is one, and * for a wildcard or a computed argument (which the accumulator receives as an expression rather than a field).
aggregate_function_name
The accumulator name for an aggregate, accounting for DISTINCT.
aggregate_output_key
The canonical output-column key an aggregate’s value is stored under in a finalized group row.
computed_group_key_name
The internal name of a computed (non-column) GROUP BY key: a stable group_{index} placeholder. The executor emits the evaluated key under it, and the response shaper reads the value back by it. The SELECT alias never reaches this name; it is a display name only.
group_key_row_name
The key a finalized group row carries one GROUP BY key under. A column key keeps its bare column name; a computed key uses computed_group_key_name.