GaneshPatil7517 commented on code in PR #19868:
URL: https://github.com/apache/datafusion/pull/19868#discussion_r2701924778


##########
datafusion/functions-aggregate/src/array_agg.rs:
##########
@@ -484,6 +524,11 @@ impl Accumulator for DistinctArrayAggAccumulator {
     fn evaluate(&mut self) -> Result<ScalarValue> {
         let mut values: Vec<ScalarValue> = 
self.values.iter().cloned().collect();
         if values.is_empty() {
+            // Return empty array instead of NULL when result is non-nullable
+            if !self.nullable_result {
+                let arr = ScalarValue::new_list(&[], &self.datatype, true);
+                return Ok(ScalarValue::List(arr));
+            }

Review Comment:
   This comment is now outdated. In the latest commit, we've corrected the 
approach:
   
   The list itself is always nullable (returns NULL for empty groups, matching 
standard SQL semantics)
   Only the inner elements' nullability is preserved from the input field
   So array_agg(non_null_column) returns List(non-null Int64) but the list 
itself can still be NULL for empty groups.



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