ozankabak commented on code in PR #12174:
URL: https://github.com/apache/datafusion/pull/12174#discussion_r1732297413
##########
datafusion/physical-plan/src/sorts/sort.rs:
##########
@@ -737,9 +738,30 @@ impl SortExec {
/// This can reduce the memory pressure required by the sort
/// operation since rows that are not going to be included
/// can be dropped.
- pub fn with_fetch(mut self, fetch: Option<usize>) -> Self {
- self.fetch = fetch;
- self
+ pub fn with_fetch(&self, fetch: Option<usize>) -> Self {
+ let mut cache = self.cache.clone();
+ if fetch.is_some() {
+ // When a theoretically unnecessary sort becomes a top-K (which
Review Comment:
In general you are right -- however, you are missing that we turn it into
`Bounded` only when the sort requirement is already satisfied. This happens
when a sort "becomes" unnecessary during one of the plan optimization steps
(and it will eventually get removed).
--
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]