Skip to content

Commit

Permalink
chore: use arg display_name as hash key instead of a hashed value
Browse files Browse the repository at this point in the history
  • Loading branch information
appletreeisyellow committed May 20, 2024
1 parent 55e3d16 commit 2ba102f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions datafusion/optimizer/src/single_distinct_to_groupby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

//! [`SingleDistinctToGroupBy`] replaces `AGG(DISTINCT ..)` with `AGG(..) GROUP BY ..`
use std::hash::BuildHasher;
use std::sync::Arc;

use crate::optimizer::ApplyOrder;
Expand Down Expand Up @@ -204,7 +203,7 @@ impl OptimizerRule for SingleDistinctToGroupBy {

// replace the distinct arg with alias
let mut index = 1;
let mut distinct_aggr_exprs = HashSet::new();
let mut group_fields_set = HashSet::new();
let mut inner_aggr_exprs = vec![];
let outer_aggr_exprs = aggr_expr
.into_iter()
Expand All @@ -221,8 +220,7 @@ impl OptimizerRule for SingleDistinctToGroupBy {
}
let arg = args.swap_remove(0);

let expr_id = distinct_aggr_exprs.hasher().hash_one(&arg);
if distinct_aggr_exprs.insert(expr_id) {
if group_fields_set.insert(arg.display_name()?) {
inner_group_exprs
.push(arg.alias(SINGLE_DISTINCT_ALIAS));
}
Expand Down

0 comments on commit 2ba102f

Please sign in to comment.