alamb commented on code in PR #25502:
URL: https://github.com/apache/datafusion/pull/25502#discussion_r4056724677
##########
datafusion/functions-nested/src/array_add.rs:
##########
@@ -120,84 +116,29 @@ impl ScalarUDFImpl for ArrayAdd {
fn array_add_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
let [array1, array2] = take_function_args("array_add", args)?;
+ let add = |a: f64, b: f64| a + b;
match (array1.data_type(), array2.data_type()) {
- (List(_), List(_)) => general_array_add::<i32>(array1, array2),
- (LargeList(_), LargeList(_)) => general_array_add::<i64>(array1,
array2),
+ (List(_), List(_)) => {
+ array_math_binary_op::<i32, _>("array_add", array1, array2, add)
+ }
+ (LargeList(_), LargeList(_)) => {
+ array_math_binary_op::<i64, _>("array_add", array1, array2, add)
+ }
(arg_type1, arg_type2) => exec_err!(
"array_add received unexpected types after coercion: {arg_type1}
and {arg_type2}"
),
}
}
-fn general_array_add<O: OffsetSizeTrait>(
Review Comment:
this is a nice reuse of existing function
##########
datafusion/functions-nested/src/utils.rs:
##########
@@ -602,4 +604,52 @@ mod tests {
assert!(needs_norm_scale(f64::INFINITY, 1));
assert!(needs_norm_scale(f64::NAN, 1));
}
+
+ /// Tests the array function supplied via `run` on small slices of a large
Review Comment:
this is a clever function
The name made it sound to me like it only checks capacity.
What do you think about calling it something like `test_sliced_list()` or
something more generic?
--
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]