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


##########
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:
   Is this saying that if the input fields are not nullable then the output 
changes to be an empty list instead of null? This does not seem logical 🤔 



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