gabotechs commented on code in PR #22326:
URL: https://github.com/apache/datafusion/pull/22326#discussion_r3258782029
##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -230,6 +230,64 @@ pub fn value_fields_with_higher_order_udf<L: Clone>(
Ok(current_fields.to_vec())
}
+ HigherOrderTypeSignature::Exact { values, lambdas } => {
Review Comment:
I imagine that this does not take into account ordering of the arguments.
For example, what happens now if you do:
```sql
any_match(x -> x > 2, [1, 2, 3])
```
With the arguments inverted? Does it fail?
##########
datafusion/functions-nested/src/array_transform.rs:
##########
@@ -97,14 +97,8 @@ impl HigherOrderUDF for ArrayTransform {
}
fn coerce_value_types(&self, arg_types: &[DataType]) ->
Result<Vec<DataType>> {
- let list = if arg_types.len() == 1 {
- &arg_types[0]
- } else {
- return plan_err!(
- "{} function requires 1 value arguments, got {}",
- self.name(),
- arg_types.len()
- );
+ let [list] = arg_types else {
+ unreachable!("arity enforced by Exact signature")
};
Review Comment:
Same as above
##########
datafusion/functions-nested/src/array_any_match.rs:
##########
@@ -117,14 +117,8 @@ impl HigherOrderUDF for ArrayAnyMatch {
}
fn coerce_value_types(&self, arg_types: &[DataType]) ->
Result<Vec<DataType>> {
- let list = if arg_types.len() == 1 {
- &arg_types[0]
- } else {
- return plan_err!(
- "{} function requires 1 value argument, got {}",
- self.name(),
- arg_types.len()
- );
+ let [list] = arg_types else {
+ unreachable!("arity enforced by Exact signature")
};
Review Comment:
What do you think about leaving it like it was before this change?
Right now, `unreachable!` is in fact unreachable because it's enforced by
the signature, but if that somehow changes in the future, this has the chance
of blowing up a process with a `panic` rather than a handled error.
--
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]