pub enum Plan {
Source(String),
Join {
left: Box<Plan>,
right: Box<Plan>,
join_key: String,
kind: JoinKind,
right_rename: BTreeMap<String, String>,
},
Filter {
input: Box<Plan>,
predicate: String,
},
Project {
input: Box<Plan>,
star: bool,
items: Vec<Proj>,
},
Aggregate {
input: Box<Plan>,
time_column: String,
window: Win,
group_by: Vec<String>,
pre: Vec<Proj>,
aggs: Vec<AggSpec>,
post: Vec<Proj>,
having: Option<String>,
trigger: Option<Trigger>,
},
TopN {
input: Box<Plan>,
group_by: Vec<String>,
order_by: String,
tie_by: Option<String>,
descending: bool,
n: usize,
},
Named {
name: String,
input: Box<Plan>,
},
Sink {
input: Box<Plan>,
name: String,
},
}Expand description
The typed logical plan. 5c-i covers the stateless shape (source → filter → project → sink); 5c-ii adds the windowed aggregate, the updating aggregate, and the joins.
Variants§
Source(String)
FROM <dataset> — a source dataset by name.
Join
FROM <left> JOIN <right> ON <key> [interval] — a two-input join.
Fields
kind: JoinKindFilter
WHERE <predicate> — the predicate as a value-dialect string.
Project
SELECT …. star = SELECT * (pass-through, no step); else the projected columns.
Aggregate
SELECT … FROM … GROUP BY <window-fn>(ts,…), <keys> — a windowed keyed aggregate. A
Some(trigger) makes it the 5a updating aggregate (early firing).
Fields
window: Winpre: Vec<Proj>Pre-aggregate computed columns (an aggregate’s expression argument, e.g. a CASE fed to
count(DISTINCT …)) — lowered to applyExpression steps BEFORE the aggregate.
post: Vec<Proj>Post-aggregate computed columns — a SELECT expression over the window/group/aggregates
(e.g. day = substring(epochToIso(windowStart), 1, 10)), lowered to applyExpression
steps AFTER the aggregate (the q15/q16 day/minute columns).
TopN
SELECT … FROM (SELECT …, ROW_NUMBER() OVER (PARTITION BY g ORDER BY c [DESC]) AS rn FROM s) WHERE rn <= n — the streaming top-N idiom → the topN operator.
Fields
Named
A CTE (WITH <name> AS (<subquery>)): the sub-plan input materialises as its own stage
under name, and downstream references to name read that stage. The multi-stage boundary —
the SQL equivalent of a named intermediate dataset in the TOML [[transforms]] DAG.
Sink
INSERT INTO <dataset> — the terminal sink dataset by name.