fn metadata_labels_keep_series_apart(
node: &NativeNode,
source_tags: &[Vec<String>],
source_metrics: &[Option<Arc<str>>],
) -> boolExpand description
Whether the metadata labels a rewrite drops are the only ones telling node’s series apart.
A range function that computes its result and timestamp in either of its forms drop
PROMQL_METADATA_LABELS - the metric name, __type__ and __unit__ - and a consumer above
them that reads a whole label set has to establish those series cannot collide once the three are
gone. Two series of one input collide only if they differed in one of the three alone,
so the drop is injective - and nothing has to be collected - when neither can tell two of them
apart:
- The name: a source bound to one metric names every series it hands over, so the name is the
same for all of them and removing it merges nothing (see
single_metric_name). A source that may hand over several - one selector that discovered several metrics, or a caller that cannot tell - is not proved, and the conservative answer is the one that collects. __type__and__unit__: both are removed along with the name, and neither is a label this walk can prove constant across a source’s series. They are ordinary labels when a source carries them as tags or a rewrite writes them, and two series that agree on everything else are one label set once they are gone. Their presence anywhere innode’s output is therefore enough to withhold the proof.
A node whose own kernel answers one series per label set - a fold, a match between two vectors, a
set operation, info, count_values - has already told those series apart, so a drop above it is
proved whatever metrics it reads (answers_one_series_per_label_set).
A node whose labels already lost the name - abs, a name-dropping window below it - has no name
of its own left to remove, and what its surviving labels tell apart is then only as good as the
metrics below it: a drop that happened on the way there removed a name without asking this walk,
so the proof asks instead that every source it reads is bound to the same one metric
(single_source_metric). Over a selector that discovered several metrics that drop folds them
together, and the answer is the one that collects.
false when the walk cannot derive node’s labels at all, because an unknown set proves nothing.
This is the whole of the drop’s proof: every arm of duplicates_canonical_labels that decides
whether a collection is needed asks it, and so does unifies_its_own_contributions at run
time, so the two cannot disagree about a merge.
What it does not answer is a key column that holds NULL in one series and '' in another, both
of which decode to no label once the empty value is dropped with the name. That pair is
deliberately outside the proof: it is a property of a nullable tag column rather than of the
labels, and every tag column of a metric-engine table is nullable, so collecting a drop for it
puts a canonical merge - and the fragmenting boundary that merge carries - over every statement
whose kernel drops the metadata labels, including the ones whose labels prove the drop injective.
The fact is still read from the resolved table
(keys_survive_metadata_drop) and the
statements whose labels prove the drop while that pair does not are still counted
(leaves_a_drop_to_the_storage_keys), so what the pair can hide stays observable even though
nothing is collected for it.