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


##########
datafusion/optimizer/src/analyzer/type_coercion.rs:
##########
@@ -763,6 +766,31 @@ impl TreeNodeRewriter for TypeCoercionRewriter<'_> {
                 });
                 Ok(Transformed::yes(new_expr))
             }
+            Expr::HigherOrderFunction(HigherOrderFunction { func, args }) => {
+                let current_fields = args
+                    .iter()
+                    .map(|arg| match arg {
+                        Expr::Lambda(_) => Ok(ValueOrLambda::Lambda(())),
+                        _ => 
Ok(ValueOrLambda::Value(arg.to_field(self.schema)?.1)),
+                    })
+                    .collect::<Result<Vec<_>>>()?;
+
+                let new_fields =
+                    value_fields_with_higher_order_udf(&current_fields, 
func.as_ref())?;
+
+                let new_args = std::iter::zip(args, new_fields)
+                    .map(|(arg, new_field)| match (&arg, new_field) {
+                        (Expr::Lambda(_lambda), ValueOrLambda::Lambda(_)) => 
Ok(arg),
+                        (Expr::Lambda(_lambda), ValueOrLambda::Value(_)) => 
plan_err!("value_fields_with_higher_order_udf return a value for a lambda 
argument"),

Review Comment:
   Actually this should be an `internal_err`, 
`value_fields_with_higher_order_udf` shouldn't return the wrong enum variant 
even with a faulty `HigherOrderUDF` implementation, like if it returned a 
wrongly sized vec in `coerce_value_types`, which is checked for and returned as 
a `plan_err` that includes the faulty function name. Fixed at 
https://github.com/apache/datafusion/pull/21679/changes/9530ded3895a5bba4357a001a2290bcd4da7ea4f,
 thanks



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