make_udf_expr_and_func

Macro make_udf_expr_and_func 

Source
macro_rules! make_udf_expr_and_func {
    ($UDF:ident, $EXPR_FN:ident, $($arg:ident)*, $DOC:expr, $SCALAR_UDF_FN:ident) => { ... };
    ($UDF:ident, $EXPR_FN:ident, $($arg:ident)*, $DOC:expr, $SCALAR_UDF_FN:ident, $CTOR:path) => { ... };
    ($UDF:ident, $EXPR_FN:ident, $DOC:expr, $SCALAR_UDF_FN:ident) => { ... };
    ($UDF:ident, $EXPR_FN:ident, $DOC:expr, $SCALAR_UDF_FN:ident, $CTOR:path) => { ... };
}
Expand description

Creates external API functions for an array UDF. Specifically, creates

  1. Single ScalarUDF instance

Creates a singleton ScalarUDF of the $UDF function named STATIC_$(UDF) and a function named $SCALAR_UDF_FUNC which returns that function named STATIC_$(UDF).

This is used to ensure creating the list of ScalarUDF only happens once.

§2. expr_fn style function

These are functions that create an Expr that invokes the UDF, used primarily to programmatically create expressions.

For example:

pub fn array_to_string(delimiter: Expr) -> Expr {
...
}

§Arguments

  • UDF: name of the ScalarUDFImpl
  • EXPR_FN: name of the expr_fn function to be created
  • arg: 0 or more named arguments for the function
  • DOC: documentation string for the function
  • SCALAR_UDF_FUNC: name of the function to create (just) the ScalarUDF
  • (optional) $CTOR: Pass a custom constructor. When omitted it automatically resolves to $UDF::new().