viirya commented on code in PR #7400:
URL: https://github.com/apache/arrow-datafusion/pull/7400#discussion_r1326485547


##########
datafusion/core/src/physical_plan/aggregates/row_hash.rs:
##########
@@ -332,8 +450,14 @@ impl Stream for GroupedHashAggregateStream {
                             self.input_done = true;
                             self.group_ordering.input_done();
                             let timer = elapsed_compute.timer();
-                            let batch = extract_ok!(self.emit(EmitTo::All));
-                            self.exec_state = 
ExecutionState::ProducingOutput(batch);
+                            if self.spill_state.spills.is_empty() {
+                                let batch = extract_ok!(self.emit(EmitTo::All, 
false));
+                                self.exec_state = 
ExecutionState::ProducingOutput(batch);
+                            } else {
+                                // If spill files exist, stream-merge them.
+                                extract_ok!(self.update_merged_stream());
+                                self.exec_state = ExecutionState::ReadingInput;

Review Comment:
   Nvm, saw it is set in `update_merged_stream`.



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