Attribute Macro common_macro::range_fn
source · #[range_fn]
Expand description
Attribute macro to convert an arithimetic function to a range function. The annotated function
should accept servaral arrays as input and return a single value as output. This procedure
macro can works on any number of input parameters. Return type can be either primitive type
or wrapped in Option
.
§Example
Take count_over_time()
in PromQL as an example:
ⓘ
/// The count of all values in the specified interval.
#[range_fn(
name = "CountOverTime",
ret = "Float64Array",
display_name = "prom_count_over_time"
)]
pub fn count_over_time(_: &TimestampMillisecondArray, values: &Float64Array) -> f64 {
values.len() as f64
}
§Arguments
name
: The name of the generatedScalarUDF
struct.ret
: The return type of the generated UDF function.display_name
: The display name of the generated UDF function.