macro_rules! export_functions {
($(($FUNC:ident, $DOC:expr, $($arg:tt)*)),*) => { ... };
(single $FUNC:ident, $DOC:expr, @config) => { ... };
(single $FUNC:ident, $DOC:expr, @config $arg:ident,) => { ... };
(single $FUNC:ident, $DOC:expr, @config $($arg:ident)*) => { ... };
(single $FUNC:ident, $DOC:expr, $arg:ident,) => { ... };
(single $FUNC:ident, $DOC:expr, $($arg:ident)*) => { ... };
}Expand description
macro that exports a list of function names as:
- individual functions in an
expr_fnmodule - a single function that returns a list of all functions
Equivalent to
pub mod expr_fn {
use super::*;
/// Return encode(arg)
pub fn encode(args: Vec<Expr>) -> Expr {
super::encode().call(args)
}
...
/// Return a list of all functions in this package
pub(crate) fn functions() -> Vec<Arc<ScalarUDF>> {
vec![
encode(),
decode()
]
}Exported functions accept:
Vec<Expr>argument (single argument followed by a comma)- Variable number of
Exprarguments (zero or more arguments, must be without commas) - Functions that require config (marked with
@configprefix)
Note on configuration construction paths:
- The convenience wrappers generated for
@configfunctions call the inner constructor withConfigOptions::default(). These wrappers are intended primarily for programmaticExprconstruction and convenience usage. - When functions are registered in a session, DataFusion will call
with_updated_config()to create aScalarUDFinstance using the session’s actualConfigOptions. This also happens when configuration changes at runtime (e.g., viaSETstatements). In short: the macro uses the default config for convenience constructors; the session config is applied when functions are registered or when configuration is updated.