haohuaijin commented on code in PR #8124:
URL: https://github.com/apache/arrow-datafusion/pull/8124#discussion_r1390185790
##########
datafusion/optimizer/src/single_distinct_to_groupby.rs:
##########
@@ -58,27 +64,37 @@ impl SingleDistinctToGroupBy {
}
}
-/// Check whether all aggregate exprs are distinct on a single field.
+/// Check whether all distinct aggregate exprs are distinct on a single field.
fn is_single_distinct_agg(plan: &LogicalPlan) -> Result<bool> {
match plan {
LogicalPlan::Aggregate(Aggregate { aggr_expr, .. }) => {
let mut fields_set = HashSet::new();
- let mut distinct_count = 0;
+ let mut aggregate_count = 0;
for expr in aggr_expr {
if let Expr::AggregateFunction(AggregateFunction {
- distinct, args, ..
+ fun,
+ distinct,
+ args,
+ filter,
+ ..
}) = expr
{
- if *distinct {
- distinct_count += 1;
- }
- for e in args {
- fields_set.insert(e.canonical_name());
+ match filter {
+ Some(_) => return Ok(false),
Review Comment:
Before this pr, we also don't support filter in
`single_distinct_to_group_by` rule. But we forget check it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]