jayzhan211 commented on code in PR #27584:
URL: https://github.com/apache/datafusion/pull/27584#discussion_r4656047913
##########
datafusion/physical-plan/src/sorts/partitioned_topk.rs:
##########
@@ -347,7 +347,10 @@ impl PartitionedTopKExec {
}
};
let partition_exprs = sort_exprs[..partition_prefix_len].to_vec();
- eq_properties.reorder(sort_exprs)?;
+
+ eq_properties.clear_groupings();
Review Comment:
@Surajsuthar Yes, please keep the fix in this operator rather than changing
`reorder`. `SortExec` returns its input unchanged when the input already
satisfies the sort (`(true, None) => Ok(input)` in `sort.rs`), so the longer
orderings `reorder` keeps are still true there; dropping them in `reorder`
would add sorts to plans that are correct today. `PartitionedTopKExec` always
re-emits rows from a heap, so it is the one that has to drop them.
##########
datafusion/physical-plan/src/sorts/partitioned_topk.rs:
##########
Review Comment:
+1. Dropping the last sentence is enough, since `sort_exprs` added above
already starts with the partition keys:
```diff
// Mirrors `add_new_ordering_expr_with_partition_by`: the
ranking
// value only ascends *within* a partition, so the ordering has
to
- // be prefixed by the partition keys. `reorder` above already
- // established that prefix.
+ // be prefixed by the partition keys.
```
--
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]