datafusion_expr::expr_rewriter

Trait FunctionRewrite

Source
pub trait FunctionRewrite: Debug {
    // Required methods
    fn name(&self) -> &str;
    fn rewrite(
        &self,
        expr: Expr,
        schema: &DFSchema,
        config: &ConfigOptions,
    ) -> Result<Transformed<Expr>>;
}
Expand description

Trait for rewriting Exprs into function calls.

This trait is used with FunctionRegistry::register_function_rewrite to to evaluating Exprs using functions that may not be built in to DataFusion

For example, concatenating arrays a || b is represented as Operator::ArrowAt, but can be implemented by calling a function array_concat from the functions-nested crate.

Required Methods§

Source

fn name(&self) -> &str

Return a human readable name for this rewrite

Source

fn rewrite( &self, expr: Expr, schema: &DFSchema, config: &ConfigOptions, ) -> Result<Transformed<Expr>>

Potentially rewrite expr to some other expression

Note that recursion is handled by the caller – this method should only handle expr, not recurse to its children.

Implementors§