Skip to main content

constant_argument

Function constant_argument 

Source
fn constant_argument(
    name: &str,
    argument: &Expr,
    position: usize,
) -> Result<f64>
Expand description

The constant argument folds to, or a rejection naming the argument and where it was read.

A parameter is a constant of the statement: a quantile, a rounding step or a clamp bound is a field of the tree, so a parameter whose value is only known at run time — time() being the real case — has nowhere to go. It is refused rather than answered from the wrong number, and the rejection names the expression, because that is what the query has to change.

name is whoever reads the argument: a call’s function name, or an aggregator’s, since quantile(0.9, x) reads a constant too. The rejection therefore names that and the position rather than calling everything a call, which would be false for an aggregate.

A quantile outside [0, 1] is not refused here: Prometheus binds it and the kernel reports -Infinity below zero and +Infinity above one, so refusing it would be this compiler inventing a rule the query engine does not have.