Commits

Andy Grove authored b24bddfd7c2
ARROW-6947: [Rust] [DataFusion] Scalar UDF support Support for Scalar UDFs, allowing custom Rust code to run as an expression. Scalar UDFs are supported both in SQL and in plans built via LogicalPlanBuilder. This will allow users of DataFusion to add their own expressions and also provides a framework to start adding useful expressions to DataFusion. The following unary math expressions are implemented as a starting point: ```rust ctx.register_udf(math_unary_function!("sqrt", sqrt)); ctx.register_udf(math_unary_function!("sin", sin)); ctx.register_udf(math_unary_function!("cos", cos)); ctx.register_udf(math_unary_function!("tan", tan)); ctx.register_udf(math_unary_function!("asin", asin)); ctx.register_udf(math_unary_function!("acos", acos)); ctx.register_udf(math_unary_function!("atan", atan)); ctx.register_udf(math_unary_function!("floor", floor)); ctx.register_udf(math_unary_function!("ceil", ceil)); ctx.register_udf(math_unary_function!("round", round)); ctx.register_udf(math_unary_function!("trunc", trunc)); ctx.register_udf(math_unary_function!("abs", abs)); ctx.register_udf(math_unary_function!("signum", signum)); ctx.register_udf(math_unary_function!("exp", exp)); ctx.register_udf(math_unary_function!("log", ln)); ctx.register_udf(math_unary_function!("log2", log2)); ctx.register_udf(math_unary_function!("log10", log10)); ``` Macros are used to generate convenience methods for creating these expressions in a logical plan, so it is now possible to write something like: ```rust let plan = LogicalPlanBuilder::scan("", "", &schema, None)? .project(vec![sqrt(col("a")), log(col("b"))])? .build()?; ``` Closes #6749 from andygrove/ARROW-6947 Authored-by: Andy Grove <andygrove73@gmail.com> Signed-off-by: Andy Grove <andygrove73@gmail.com>