Rindle docs and package mapSkip to main content

build_pipeline

Function build_pipeline 

Source
pub fn build_pipeline(
    graph: &mut Graph,
    ast: &Ast,
    resolve: &impl Fn(&str) -> Option<(NodeId, SourceSchema)>,
) -> Result<NodeId, BuildError>
Expand description

Lower an Ast into a wired pipeline in graph, returning the top operator (the one a sink attaches to via Graph::set_sink_edge). The port of JS buildPipeline/buildPipelineInternal (builder.ts:256) for the built operator subset: a source connection carrying its pushed-down where (ConnectionFilters) plus a chain of parent-driven relationship joins.

resolve maps a table name to its already-created source NodeId and a clone of that source’s Schema — the builder seeds no sources (the test harness / view layer owns them, mirroring JS delegate.getSource). A relationship child is resolved the same way.

In scope: table; where (AND/OR/leaves lowered to one connection RowPredicate via [create_predicate], the memory leaf’s filter — no Filter operators are built because a subquery-free where is fully applied at the source, matching JS fullyAppliedFilters); order_by (PK-completed at lowering so the source’s connect assertion holds); and related relationships — sibling (multiple relationships on one row, each a Join stacked on the prior) and nested (a relationship whose child has its own related, lowered to a Join feeding the parent join’s child port). Joins carry a port-tagged OutEdge so they can feed each other (Graph::set_out_edge).

start lowers to a Skip and limit to a Take (after start, before related), each carried on a port-tagged edge so it can feed a relationship join.

EXISTS (where correlated subqueries) is fully lowered — flipped + non-flipped, nested, under OR (the union fan), and AND-within-AND (the where is structurally flattened by [normalize_pipeline_ast] first) — as is related, limit/start, and nested Child pushes. select determines the output projection through view_schema; required keys and query inputs remain available to the pipeline.

Out of scope → BuildError::Unsupported: flipped NOT EXISTS, an EXISTS subquery carrying start or nested related, and a bare EXISTS subquery alias colliding with a materialized related of the same name (a genuine one-slot-per-name limitation, not a normalization artifact — see normalize_pipeline_ast / WS05.4).