Rindle docs and package mapSkip to main content

view_schema

Function view_schema 

Source
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_pipeline resolves aliases against via rel_slot), so dataflow slots line up with the view’s;
  • a slot whose name is a related alias of this frame is in view: its child schema is built recursively (its sort PK-completed by resolve_sort) — a RelDef::related. On a duplicate alias the last writer wins, matching the dataflow’s dedup_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-only RelDef::new (no child schema), which the View’s apply_change skips (rel_child(slot) is None).

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.