jorgecarleitao commented on a change in pull request #7974:
URL: https://github.com/apache/arrow/pull/7974#discussion_r471708914



##########
File path: rust/datafusion/src/logicalplan.rs
##########
@@ -364,22 +364,25 @@ pub enum Expr {
         /// List of expressions to feed to the functions as arguments
         args: Vec<Expr>,
         /// The `DataType` the expression will yield
-        return_type: DataType,
+        return_type: ReturnType,
     },
     /// Wildcard
     Wildcard,
 }
 
-impl Expr {
-    /// Find the `DataType` for the expression
-    pub fn get_type(&self, schema: &Schema) -> Result<DataType> {
+impl DataTyped for Expr {
+    fn get_type(&self, schema: &Schema) -> Result<DataType> {
         match self {
             Expr::Alias(expr, _) => expr.get_type(schema),
             Expr::Column(name) => 
Ok(schema.field_with_name(name)?.data_type().clone()),
             Expr::Literal(l) => l.get_datatype(),
             Expr::Cast { data_type, .. } => Ok(data_type.clone()),
-            Expr::ScalarFunction { return_type, .. } => 
Ok(return_type.clone()),
-            Expr::AggregateFunction { return_type, .. } => 
Ok(return_type.clone()),
+            Expr::ScalarFunction {
+                args, return_type, ..
+            } => return_type(&args.iter().map(|x| x.as_datatyped()).collect(), 
schema),

Review comment:
       not very beautiful, but was unable to find a better pattern for this :(




----------------------------------------------------------------
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:
[email protected]


Reply via email to