One input a DEFINE predicate reads. A predicate is lowered to an expression over a synthetic
row whose i-th column is produced by slots[i]; the executor materializes that row for each
candidate row from the sorted partition and the in-progress matchβs labels.
Maps each InputRef in a bound DEFINE predicate to a DefineSlot: navigation placeholders
(index >= nav_base) to their pre-resolved slot; variable-qualified columns to a self slot (the
defined variable, or an unqualified/raw-input reference) or a running slot (another variable).
Checks that every measure InputRef is pattern-variable-qualified (alias block >= 1). A
reference into block 0 is the raw input β an unqualified or table-qualified column with no
pattern-variable navigation meaning.
One navigation input that a measure expression reads. A measure is lowered to an expression over
a synthetic row whose i-th column is produced by slots[i]; the executor materializes that row
per match (the column values are only knowable once the match and its per-row labels are found)
and then evaluates the expression.
Extracts row-pattern navigation functions (PREV/NEXT/FIRST/LAST) from a DEFINE
predicate AST, replacing each with a synthetic placeholder column and recording the corresponding
DefineSlot. Functions are handled because they do not bind as ordinary scalar functions;
plain variable-qualified columns are left to bind normally and are mapped later.
Rewrites each pattern-variable-qualified InputRef in a measure expression to an InputRef into
the synthetic per-match row, recording a deduplicated LAST(var.col) slot for it.
Decodes a measure InputRef back to the pattern variable(s) and input column it references.
Pattern variables and SUBSET names are each registered as an alias block of width
input_col_num after the input columns, in alias_names order; so block 0 is the raw input (an
unqualified reference, unsupported) and block k + 1 is alias_names[k]. A SUBSET name
resolves to its member variables; a plain variable resolves to itself.
How a DefineSlot resolves against the row being tested for membership in a pattern
variable. The wire enum, used directly (documented in stream_plan.proto); see
MeasureSlotKind for why there is no parallel binder-side enum.
How a MeasureSlot resolves against the rows of a match. This is the wire enum used
directly (the variants are documented in stream_plan.proto): a parallel binder-side enum
would only add a conversion layer for the plan node to keep in lockstep.
Collect the distinct pattern-variable names appearing in a pattern, unioned with the DEFINE
symbols. The union is defensive: bind_match_recognize rejects any DEFINE symbol absent from
the pattern before this runs, so the two sets are equal there.
Lower a WITHIN bound into the two expressions the executor consumes: the span predicate over a
synthetic [last_order_key, first_order_key] row, and the per-row deadline over a synthetic
[first_order_key] row.
Per pattern variable: the minimum number of rows a match has necessarily consumed before a row
can be labeled with that variable β its minimum distance from the match start.
Rejects function-call modifiers on the specially-lowered MATCH_RECOGNIZE functions: the
MEASURES aggregates and FIRST/LAST/CLASSIFIER, and the DEFINE navigation functions
PREV/NEXT/FIRST/LAST. Both lowerings match these by name and read only the argument list,
so a modifier would be dropped and the plain call evaluated, silently producing wrong results.
clause names the clause for the error message (MEASURES or DEFINE).
Rejects a PERMUTE with too many variables. This is the only enforcement point: the pattern
lowering in optimizer::plan_node::stream_match_recognize no longer repeats the check, since every
pattern that reaches it has passed validate_pattern.