DerGut commented on code in PR #15692: URL: https://github.com/apache/datafusion/pull/15692#discussion_r2040698187
########## datafusion/physical-plan/src/sorts/sort.rs: ########## @@ -529,6 +523,12 @@ impl ExternalSorter { /// Sorts the in-memory batches and merges them into a single sorted run, then writes /// the result to spill files. async fn sort_and_spill_in_mem_batches(&mut self) -> Result<()> { + if self.in_mem_batches.is_empty() { Review Comment: This was my first version to fix the internal error. Later I decided to move the logic to the caller (`ExternalSorter::insert_batch`) because the name `ExternalSorter::sort_and_spill_in_mem_batches` kind of implies that it only makes sense to call when there are in-mem batches. Now we handle this case in two places. I can remove the handling here unless a more defensive approach is desired. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org