Refactor `SortExec`'s buffered batches for better code readability
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Is your feature request related to a problem or challenge?
Reference https://github.com/apache/datafusion/pull/15355#discussion_r2009077643 https://github.com/apache/datafusion/pull/15355#discussion_r2009002846
The high-level execution logic of `SortExec` is described in https://github.com/apache/datafusion/blob/main/datafusion/physical-plan/src/sorts/sort.rs, now a single field `in_mem_batches` is used to represent buffered data in different stage: during different time, it can be interpreted as either unordered input batch, or globally sorted batch:
https://github.com/apache/datafusion/blob/5210a2bac32e43dc7bf6e7e6000cdeaf2833c06e/datafusion/physical-plan/src/sorts/sort.rs#L229
This approach has poor understandability and is also error-prone, see the idea in reference discussion for improvements.
### Describe the solution you'd like
_No response_
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.