Skip to content

Commit a269ffd

Browse files
committed
fix: SortExec.fetch was 0 when create_filter was called
create_filter() was called before new_sort.fetch was set, so DynamicFilterPhysicalExpr.fetch was always 0 (or None from old self). Fix by setting fetch before creating the filter. This was the root cause of stats init and cumulative prune not triggering on CI — fetch=0 meant "no rows needed" → skip.
1 parent 839ab5a commit a269ffd

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • datafusion/physical-plan/src/sorts

datafusion/physical-plan/src/sorts/sort.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -962,14 +962,16 @@ impl SortExec {
962962
if fetch.is_some() && is_pipeline_friendly {
963963
cache = cache.with_boundedness(Boundedness::Bounded);
964964
}
965-
let filter = fetch.is_some().then(|| {
966-
// If we already have a filter, keep it. Otherwise, create a new one.
967-
self.filter.clone().unwrap_or_else(|| self.create_filter())
968-
});
969965
let mut new_sort = self.cloned();
970966
new_sort.fetch = fetch;
971967
new_sort.cache = cache.into();
972-
new_sort.filter = filter;
968+
new_sort.filter = fetch.is_some().then(|| {
969+
// If we already have a filter, keep it. Otherwise, create a new one.
970+
// Must be called after setting fetch so DynamicFilter gets the K value.
971+
self.filter
972+
.clone()
973+
.unwrap_or_else(|| new_sort.create_filter())
974+
});
973975
new_sort
974976
}
975977

0 commit comments

Comments
 (0)