pub struct Ast {Show 14 fields
pub schema: Option<Box<str>>,
pub table: Box<str>,
pub alias: Option<Box<str>>,
pub select: Option<Vec<Box<str>>>,
pub where: Option<Condition>,
pub related: Vec<CorrelatedSubquery>,
pub start: Option<Bound>,
pub limit: Option<u32>,
pub one: bool,
pub aggregate: Option<Aggregate>,
pub aggregate_precomputed: bool,
pub group_by: Vec<Box<str>>,
pub having: Option<Condition>,
pub order_by: Vec<OrderPart>,
}Expand description
The query AST (Ast, ast.ts:217-243). table is the only required field;
every other wire field is optional. Default enables struct-update syntax for
hand-written test expectations. Deserializes from the JS wire JSON (camelCase
keys; absent ⇒ None/empty).
Fields§
§schema: Option<Box<str>>Postgres schema namespace — opaque pass-through (ast.ts:218).
table: Box<str>Source table name. The only required field.
alias: Option<Box<str>>Subquery alias (the relationship name, when this is a sub/exists child).
select: Option<Vec<Box<str>>>Projection. None ⇒ select all columns; Some(cols) ⇒ just cols.
Sanctioned non-wire extension (see module docs); serialized only when set.
where: Option<Condition>Filter tree.
Child subqueries (materialized relationships). Empty ⇒ none.
start: Option<Bound>Paging lower bound.
limit: Option<u32>Row limit.
one: bool.one() — return a single row: the result is presented as one object (or
null/absent) instead of an array. Query intent recorded on the AST; the
engine stays plural internally and the single-element unwrap happens at the
result boundary (the builder lowers one onto the view
Schema’s singular flag). A .one() query also sets
limit = 1. On a related subquery, one makes that relationship singular.
aggregate: Option<Aggregate>Aggregate this (sub)query’s rows instead of materializing them
(REDUCE-DESIGN.md). None ⇒ ordinary row output; Some on a related
subquery ⇒ a relationship aggregate the builder lowers to a reduce + a
scalar-projected singular relationship (§9). Absent on the wire ⇒ None.
aggregate_precomputed: boolThe aggregate is precomputed — its (group_key…, value)
rows are supplied as a (synthetic) source table rather than reduced from child
rows. Set by the normalized client’s AST rewrite (AGGREGATE-SYNC-DESIGN.md §3.3):
the server ships the reduce’s output as a base table, and the client reads it with
a plain singular join + the same scalar projection — not a reduce, which
would recount the already-aggregated rows. Only meaningful alongside aggregate;
absent on the wire ⇒ false (the ordinary reduce-backed relationship aggregate).
group_by: Vec<Box<str>>Top-level GROUP BY columns (names, not ColIds), meaningful only alongside a
root aggregate (REDUCE-DESIGN.md §8). Empty + aggregate
set produces one global aggregate row; non-empty produces one
[group…, aggregate] row per distinct value-tuple. The builder lowers this to an
eager grouped reduce feeding the View. Distinct from a relationship
aggregate’s grouping, which is implicit (the correlation child key). Absent on
the wire ⇒ empty.
having: Option<Condition>HAVING — a filter over the post-aggregation rows of a root
aggregate (REDUCE-DESIGN.md §4: a HAVING filter sits
directly above the reduce). The condition addresses the aggregate’s output
columns — the group_by columns and the synthetic count,
sum, or avg column — not base-table columns. The builder lowers it to a Filter sub-graph
above the reduce (whereas where filters rows below it);
the Filter edit-split turns a group crossing the predicate threshold into an
Add/Remove, so it is maintained incrementally for free. Absent ⇒ None.
order_by: Vec<OrderPart>Sort spec (names, not ColIds). Empty ⇒ none. Wire key orderBy.