isidentical commented on code in PR #3593:
URL: https://github.com/apache/arrow-datafusion/pull/3593#discussion_r978356394


##########
datafusion/core/src/physical_plan/sorts/sort.rs:
##########
@@ -124,6 +124,20 @@ impl ExternalSorter {
             // calls to `timer.done()` below.
             let _timer = tracking_metrics.elapsed_compute().timer();
             let partial = sort_batch(input, self.schema.clone(), &self.expr, 
self.fetch)?;
+            // The resulting batch might be smaller than the input batch if 
there
+            // is an propagated limit.
+            if self.fetch.is_some() {
+                let new_size = batch_byte_size(&partial.sorted_batch);
+                let size_delta = size.checked_sub(new_size).unwrap_or_else(|| {
+                    panic!(

Review Comment:
   Makes sense, should be fixed now!



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