Skip to content

Commit 99902be

Browse files
adriangbclaude
andcommitted
refactor: drop unreachable GroupingSet guard in EliminateGroupByConstant
`Aggregate::try_new` calls `enumerate_grouping_sets`, which folds a group list that contains a grouping set into one `GroupingSet` expression. Thus `group_expr.len() == 1` for such an aggregate, and the first two conditions already make the rule return. The extra check can not fire. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2a7c2fa commit 99902be

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

‎datafusion/optimizer/src/eliminate_group_by_constant.rs‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@ impl OptimizerRule for EliminateGroupByConstant {
7070
// ungrouped aggregate, which changes query semantics (grouped
7171
// aggregates produce an empty result set on an empty input,
7272
// whereas ungrouped aggregates return a single row).
73-
// A grouping set adds output fields that do not map one to one
74-
// to `group_expr`, so the rule also leaves it unchanged.
75-
if redundant_count == 0
76-
|| redundant_count == aggregate.group_expr.len()
77-
|| aggregate
78-
.group_expr
79-
.iter()
80-
.any(|expr| matches!(expr, Expr::GroupingSet(_)))
81-
{
73+
if redundant_count == 0 || redundant_count == aggregate.group_expr.len() {
8274
return Ok(Transformed::no(LogicalPlan::Aggregate(aggregate)));
8375
}
8476

0 commit comments

Comments
 (0)