Skip to content

Commit a46f7bc

Browse files
committed
Allow pushdown if grouping set is empty
1 parent ee82e5d commit a46f7bc

File tree

1 file changed

+4
-1
lines changed
  • datafusion/physical-plan/src/aggregates

1 file changed

+4
-1
lines changed

datafusion/physical-plan/src/aggregates/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,10 @@ impl ExecutionPlan for AggregateExec {
10571057
.flat_map(|(expr, _)| collect_columns(expr))
10581058
.collect();
10591059

1060-
if !filter_columns.is_subset(&grouping_columns) {
1060+
// For aggregates with GROUP BY: only allow pushdown if filters reference grouping columns
1061+
// For aggregates without GROUP BY (e.g., SELECT COUNT(*)): allow pushdown of any filter
1062+
// since we're aggregating all rows into a single group anyway
1063+
if !grouping_columns.is_empty() && !filter_columns.is_subset(&grouping_columns) {
10611064
// Filters reference non-grouping columns - not safe to push through
10621065
let unsupported_filters: Vec<_> = parent_filters
10631066
.into_iter()

0 commit comments

Comments
 (0)