alamb commented on a change in pull request #7967:
URL: https://github.com/apache/arrow/pull/7967#discussion_r471442333



##########
File path: rust/datafusion/src/sql/planner.rs
##########
@@ -523,10 +523,14 @@ impl<S: SchemaProvider> SqlToRel<S> {
 
                             let mut safe_args: Vec<Expr> = vec![];
                             for i in 0..rex_args.len() {
-                                safe_args.push(
-                                    rex_args[i]
-                                        .cast_to(fm.args()[i].data_type(), 
schema)?,
-                                );
+                                let expr = if fm.args()[i]
+                                    .contains(&rex_args[i].get_type(schema)?)
+                                {
+                                    rex_args[i].clone()
+                                } else {
+                                    rex_args[i].cast_to(&fm.args()[i][0], 
schema)?

Review comment:
       makes sense -- I guess I would suggest we add a test to ensure the 
system behaves reasonably (aka generates an error rather than a crash) with 0 
argument UDFs -- but if there is something challenging about implementing them 
it doesn't have to be done in this PR




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to