kosiew commented on code in PR #23359:
URL: https://github.com/apache/datafusion/pull/23359#discussion_r3577142697
##########
datafusion/physical-plan/src/sorts/sort_preserving_merge.rs:
##########
@@ -382,7 +382,9 @@ impl ExecutionPlan for SortPreservingMergeExec {
}
fn statistics_with_args(&self, args: &StatisticsArgs) ->
Result<Arc<Statistics>> {
- args.compute_child_statistics(&self.input, None)
+ let stats =
+ Arc::unwrap_or_clone(args.compute_child_statistics(&self.input,
None)?);
+ Ok(Arc::new(stats.with_fetch(self.fetch, 0, 1)?))
}
fn supports_limit_pushdown(&self) -> bool {
Review Comment:
Would it make sense to also override `cardinality_effect()` here, returning
`LowerEqual` when `self.fetch.is_some()` and `Equal` otherwise, similar to
`SortExec`? This PR correctly fixes the statistics-based costing, but
`SortPreservingMergeExec` with a fetch still reports the default `Unknown`
cardinality effect. As a result, optimizer logic that relies on cardinality
metadata instead of statistics may not see the same fetch-aware behavior.
--
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]