pub fn compile(
stmt: &EvalStmt,
input: Arc<SeriesSchema>,
ordering: SeriesOrdering,
) -> Result<NativeTree>Expand description
Compiles stmt into a tree that reads input and evaluates the statement’s expression over it.
input is the raw series schema the caller bound from the table, and the caller has to apply the
selector’s matchers before binding it: __field__, __schema__ and __database__ select rows
and fields the same way they do in the existing planner, and the AST cannot restate that
afterwards. input.fields is therefore the post-__field__ field set, not the table’s; a caller
that binds every field of the table instead compiles a different, wrong window, because
rate(x{__field__="a"}[5m]) over fields [a, b] would fold two fields where the planner folds
one.
ordering is what the caller’s scan guarantees, and the tree records it rather than assuming
one. Only Contiguous and KeyThenTime are accepted: every shape this compiler accepts reads
one series to its last chunk before the next, so an Interleaved declaration is refused at the
entry, before any shape is built — the bare selector included, which returns before a window
exists — and a shape added later inherits the refusal instead of restating it.
[NativeNode::validate] refuses the same ordering in its Instant and Window branches, as a
backstop for a tree built some other way.
This compatibility entry accepts exactly one selector. Call compile_selectors to retain
each selector’s requirement and binding when compiling more than one input.