gstvg commented on code in PR #18921:
URL: https://github.com/apache/datafusion/pull/18921#discussion_r3022045503


##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -199,6 +203,13 @@ impl ExprSchemable for Expr {
                 // Grouping sets do not really have a type and do not appear 
in projections
                 Ok(DataType::Null)
             }
+            Expr::HigherOrderFunction(_func) => {
+                Ok(self.to_field(schema)?.1.data_type().clone())
+            }
+            Expr::Lambda(Lambda { params: _, body }) => body.get_type(schema),

Review Comment:
   It's either this, `DataType::Null` or an error. I don't have a strong 
opinion on this, actually. Right now, the only place I call it is literally 
like this:
   
   
   ```rust
   .map(|arg: Expr| {
       let field = arg.to_field(schema)?.1;
           match arg {
               Expr::Lambda(_lambda) => Ok(ValueOrLambda::Lambda(field)),
               _ => Ok(ValueOrLambda::Value(field)),
           }
   })
   ```
   
   We can just change it to 
   
   ```rust
   .map(|arg: Expr| {
           match arg {
               Expr::Lambda(lambda) => 
Ok(ValueOrLambda::Lambda(lambda.body.to_field(schema)?.1)),
               _ => Ok(ValueOrLambda::Value(arg.to_field(schema)?.1)),
           }
   })
   ```
   
   During higher order function type coercion, arguments are ignored if they 
are a lambda and only value arguments are checked and coerced so the return 
type for a lamba is irrelevant.
   
   Some other expressions return `DataType::Null` like logical `Placeholder` 
without a specifed type, `Wildcard` and `GroupingSet` and physical `NoOp` and 
`UnknownColumn`. If you think that's better I'm happy to change it



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to