fn shape_metric_sink_source(
from_id: GlobalId,
from_desc: &RelationDesc,
) -> (MirRelationExpr, RelationDesc)Expand description
Extends the metric sink’s imported relation with the row-wise shaping the operator otherwise
has to do in Rust: coalesces labels/help to their identity element, and adds two columns
the operator reads instead of parsing strings on its hot path:
metric_kind(Int32, nullable):0forgauge,1forcounter,NULLfor any othermetric_type.name_valid(Bool, nullable): whethermetric_namematches the Prometheus metric-name grammar (seeMETRIC_NAME_PATTERN). The operator treats aNULLthe same asfalse.
No row is dropped or filtered here: the operator still needs every row, including the ones
this marks invalid, to count skipped/null_values. Only the pure per-row shaping moves to
MIR. Dedup, collision detection, and family-conflict counting stay in the operator, because
they need cross-row state (the frontier-gated fold) that a Map can’t express.
TODO: A full move would also express the dedup/collision/family-conflict logic in MIR (e.g.
via Reduce + FirstValue), collapsing the operator to a plain fold over the live set. That
full move is deferred: the tiebreak fidelity that logic needs is easier to keep correct
hand-written and unit-tested for now.