izveigor commented on code in PR #7242:
URL: https://github.com/apache/arrow-datafusion/pull/7242#discussion_r1290550378


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -2150,6 +2150,61 @@ pub fn array_has_all(args: &[ArrayRef]) -> 
Result<ArrayRef> {
     Ok(Arc::new(boolean_builder.finish()))
 }
 
+macro_rules! array_sum_internal(
+    ($ARRAY:expr, $ARRAY_TYPE:ident, $DATA_TYPE:ident) => {{
+        let mut values = vec![];
+        for arr in $ARRAY.iter() {
+            if let Some(arr) = arr {
+                let arr = downcast_arg!(arr, $ARRAY_TYPE);
+                let sum = arr.values().iter().sum::<$DATA_TYPE>();
+                values.push(sum);
+            }
+        }
+        Ok(Arc::new($ARRAY_TYPE::from(values)))
+    }}
+);
+
+/// array_aggregate SQL function
+pub fn array_aggregate(args: &[ArrayRef]) -> Result<ArrayRef> {
+    assert_eq!(args.len(), 2);
+    let func_name = args[1].as_string::<i32>().value(0);
+    let args = &args[0..1];
+    match func_name {
+        "sum" => array_sum(args),

Review Comment:
   Agree with @alamb. Only I want to say that `array_aggregate` function must 
only accept aggregate functions with **one** argument.



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

Reply via email to