Skip to main content

propagate

Function propagate 

Source
pub(super) fn propagate(
    binary: &BinaryExpr,
    left_tags: &[String],
    right_tags: &[String],
    left_field_labels: &[String],
    right_field_labels: &[String],
) -> Option<BinaryExpr>
Expand description

Copies label matchers from one operand of binary to the other, so both scans discard non-joining series instead of the join.

Arithmetic operands are inner-joined on their matching labels with plain column equality, so a matcher on a matching label already holds for every surviving pair. Copying it to the other operand can only drop rows that had no partner, whatever the matcher kind, and NULL pairs only with NULL. Nor can it split a match group, whose series agree on every matching label: a propagated matcher removes whole groups, so the cardinality check still sees every group that takes part in the matching. A duplicate in a group without a partner goes unreported as a result, where Prometheus fails the query on it. Grouped matching is conservatively restricted to a provably unique one-side operand.

left_tags and right_tags are the tag columns of the planned operands: a matcher may just as well constrain a value field, which the parsed expression does not distinguish from a label. Matchers can cross an aggregate only on labels that partition its input. left_field_labels and right_field_labels exclude value fields promoted to grouping labels: filtering them before sample selection could replace the latest sample with an older one (#9242).

Whether a matcher reaches a scan is decided per receiving operand (preserves_filter), so propagation is one-way when only one of the two can take the filter.