HaoYang670 commented on a change in pull request #1734:
URL: https://github.com/apache/arrow-datafusion/pull/1734#discussion_r800000256
##########
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:
Thank you @Jimexist !
And alamb 's opinion of the trade-off between macro and function call is
here:
https://github.com/apache/arrow-datafusion/issues/1718#issuecomment-1026239024
--
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]