wudidapaopao commented on code in PR #25849:
URL: https://github.com/apache/datafusion/pull/25849#discussion_r4135636285


##########
datafusion/functions-aggregate/src/count.rs:
##########
@@ -614,6 +651,19 @@ impl Accumulator for CountAccumulator {
         Ok(())
     }
 
+    fn update_batch_with_num_rows(
+        &mut self,
+        values: &[ArrayRef],
+        num_rows: usize,
+    ) -> Result<()> {
+        if values.is_empty() {
+            self.count += num_rows as i64;
+            Ok(())
+        } else {
+            self.update_batch(values)
+        }
+    }
+
     fn retract_batch(&mut self, values: &[ArrayRef]) -> Result<()> {

Review Comment:
   You're right that `retract_batch` would fail with nullary input. This PR 
intentionally does not support nullary aggregate windows: `create_window_expr` 
rejects empty arguments, and `COUNT(*)` used as a window aggregate still uses 
`COUNT(1)`. Therefore, `retract_batch` cannot receive empty `values` on the 
normal path, so this PR does not introduce a regression.



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