Skip to main content

map_compare_literal

Function map_compare_literal 

Source
pub fn map_compare_literal(
    schema: &Arc<SeriesSchema>,
    series: &Series,
    comparison: Comparison,
    scalar: ScalarOperand,
) -> Result<(Option<Series>, bool)>
Expand description

Compares a vector with a constant scalar, dropping the samples that have no comparison rather than failing the query.

Prometheus compares float samples only: a histogram has no ordering against a scalar, so the position it holds answers nothing. The existing planner says so with an info and answers no value there (NativeHistogramDrop, prom_token_to_binary_expr_builder in query::promql::planner), which is the behaviour mirrored here. The second element of the answer reports whether a histogram was dropped, so the caller can record that info once per chunk instead of once per position.

The literal form of a filter: None still means nothing passed, so the caller hands on no value for this chunk.