We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7453e4d commit 96e7101Copy full SHA for 96e7101
1 file changed
datafusion/expr/src/logical_plan/plan.rs
@@ -3770,11 +3770,11 @@ impl PartialOrd for Aggregate {
3770
/// Returns 0 when no grouping set is duplicated.
3771
fn max_grouping_set_duplicate_ordinal(group_expr: &[Expr]) -> usize {
3772
if let Some(Expr::GroupingSet(GroupingSet::GroupingSets(sets))) = group_expr.first() {
3773
- sets.iter()
3774
- .map(|set| sets.iter().filter(|other| *other == set).count())
3775
- .max()
3776
- .unwrap_or(0)
3777
- .saturating_sub(1)
+ let mut counts: HashMap<&[Expr], usize> = HashMap::new();
+ for set in sets {
+ *counts.entry(set).or_insert(0) += 1;
+ }
+ counts.into_values().max().unwrap_or(0).saturating_sub(1)
3778
} else {
3779
0
3780
}
0 commit comments