Jimexist commented on a change in pull request #1734:
URL: https://github.com/apache/arrow-datafusion/pull/1734#discussion_r799970574
##########
File path: datafusion/src/logical_plan/expr.rs
##########
@@ -2189,6 +2189,20 @@ pub fn exprlist_to_fields<'a>(
expr.into_iter().map(|e| e.to_field(input_schema)).collect()
}
+/// Calls a named built in function
+/// ```
+/// use datafusion::logical_plan::*;
+///
+/// // create the expression sin(x) < 0.2
+/// let expr = call_builtin_scalar_fn("sin",
vec![col("x")]).unwrap().lt(lit(0.2));
+/// ```
+pub fn call_builtin_scalar_fn(name: impl AsRef<str>, args: Vec<Expr>) ->
Result<Expr> {
+ match name.as_ref().parse::<functions::BuiltinScalarFunction>() {
+ Ok(fun) => Ok(Expr::ScalarFunction { fun, args }),
+ Err(e) => Err(e),
+ }
Review comment:
i wonder if it makes sense to make it a macro rather than a function
call so that nonexisteng built-in functions will be caught during compile time
not runtime
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]