pub fn view_schema(
ast: &Ast,
resolve: &impl Fn(&str) -> Option<(NodeId, SourceSchema)>,
) -> Result<Schema, BuildError>Expand description
Derive the production-View hierarchical schema for ast,
resolving table names through the same resolve closure that build_pipeline uses.
build_pipeline returns only the top NodeId, so the View’s tree shape is
reconstructed here from the Ast. The schema is the view shape: a relationship slot
carries a child schema iff it is in view (a join-only RelDef::new is out of view).
- the slot order is the source schema’s declared relationship order (the same
order
build_pipelineresolves aliases against viarel_slot), so dataflow slots line up with the view’s; - a slot whose name is a
relatedalias of this frame is in view: its child schema is built recursively (its sort PK-completed byresolve_sort) — aRelDef::related. On a duplicate alias the last writer wins, matching the dataflow’sdedup_related_by_alias, so the View’s child schema/sort is derived from the same subquery the Join is built from; - every other declared slot — an EXISTS gating relationship, or one unused by this
Ast— is out of view: a join-onlyRelDef::new(no child schema), which the View’sapply_changeskips (rel_child(slot)isNone).
The top frame’s sort is the resolved order_by; top-level is plural.
This is the production seam graduated out of testkit: the wasm client (WS01) and the
testkit runners both derive the view shape here, so there is one derivation, not two.