pub enum Aggregate {
Count,
Sum(Box<str>),
Avg(Box<str>),
}Expand description
An aggregate over a (correlated) subquery’s rows (REDUCE-DESIGN.md).
Set on a Ast that is a related subquery, it marks that relationship as a
relationship aggregate — issue { commentCount: count(comments) } — which the
builder (08) lowers to a grouped reduce + a scalar-projected singular relationship
(§9) instead of a row-materializing join. Set on the root Ast, it is a top-level
aggregate (SELECT count(*) FROM …, optionally with group_by/having).
Sum/Avg carry the column name they aggregate (resolved to a child/source
ColId by the builder). All three are invertible, so
reduce maintains them from a pure delta stream. Serde is externally tagged: Count
⇒ the bare string "count"; Sum(c) ⇒ {"sum": c}; Avg(c) ⇒ {"avg": c}.
Variants§
Count
count(*) over the subquery’s (filtered) rows.
Sum(Box<str>)
sum(col) over the subquery’s (filtered) rows — Σ of the non-NULL values.
Avg(Box<str>)
avg(col) over the subquery’s (filtered) rows — sum / count of the non-NULL
values (NULL when there are none).