gstvg commented on code in PR #21679:
URL: https://github.com/apache/datafusion/pull/21679#discussion_r3104913454
##########
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(¤t_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"),
+ (_, ValueOrLambda::Value(new_field)) =>
arg.cast_to(new_field.data_type(), self.schema),
+ (_, ValueOrLambda::Lambda(_)) =>
plan_err!("value_fields_with_higher_order_udf return a lambda for a value
argument"),
Review Comment:
Also at
https://github.com/apache/datafusion/pull/21679/changes/9530ded3895a5bba4357a001a2290bcd4da7ea4f
--
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]