ahmed-mez commented on code in PR #18906:
URL: https://github.com/apache/datafusion/pull/18906#discussion_r2565574139


##########
datafusion/physical-plan/src/aggregates/row_hash.rs:
##########
@@ -1164,11 +1189,11 @@ impl GroupedHashAggregateStream {
     fn set_input_done_and_produce_output(&mut self) -> Result<()> {
         self.input_done = true;
         self.group_ordering.input_done();
+        self.group_values.input_done();
         let elapsed_compute = self.baseline_metrics.elapsed_compute().clone();
         let timer = elapsed_compute.timer();
         self.exec_state = if self.spill_state.spills.is_empty() {
-            let batch = self.emit(EmitTo::All, false)?;
-            batch.map_or(ExecutionState::Done, ExecutionState::ProducingOutput)
+            ExecutionState::DrainingGroups

Review Comment:
   The way I see it `ExecutionState::ProducingOutput` is not doing anything 
wrong per se, it's still useful for producing results while still reading input 
(e.g. in sorted input scenario) which requires a different (more involved) 
handling compared to `ExecutionState::DrainingOutput`.
   
   The fundamental problem was in the way `set_input_done_and_produce_output` 
emitted results, not in the `ExecutionState::ProducingOutput` implementation.
   
   I do acknowledge though that the the current PR added some complexity to the 
code flow and I'm happy to explore ways to simplify it.



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