Skip to main content

scalar_function_call

Function scalar_function_call 

Source
fn scalar_function_call(
    context: &Context<'_>,
    name: &str,
    args: &[Box<Expr>],
) -> Result<Option<NativeNode>>
Expand description

Binds max_of(a, b) or min_of(a, b), whose arguments are both scalars, or returns None for any other call.

Prometheus types both as (scalar, scalar) -> scalar, so what the call wrote is two scalar expressions rather than a vector and its parameters: the first argument is the map’s input and the second is its one parameter, and the answer is a scalar on the grid they are evaluated on. A constant argument is bound as the number it folds to (compile_expr); as the input, that number is the one chunk the map materializes, so a call of two constants reads no input at all. A vector argument is refused here: it is not a shape the kernel could compute, and a function of two scalars has no vector form to fold.