ygf11 commented on code in PR #5345:
URL: https://github.com/apache/arrow-datafusion/pull/5345#discussion_r1113983497
##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1773,6 +1773,22 @@ impl Aggregate {
_ => plan_err!("Could not coerce into Aggregate!"),
}
}
+
+ pub fn is_distinct(&self) -> datafusion_common::Result<bool> {
+ let group_expr_size = self.group_expr.len();
+ if !self.aggr_expr.is_empty() || group_expr_size !=
self.schema.fields().len() {
+ return Ok(false);
+ }
+
+ let expected_group_exprs = expand_wildcard(&self.schema,
self.input.as_ref())?;
+ let expected_expr_set =
expected_group_exprs.iter().collect::<HashSet<&Expr>>();
+ let group_expr_set =
self.group_expr.iter().collect::<HashSet<&Expr>>();
+ Ok(group_expr_set
+ .intersection(&expected_expr_set)
+ .collect::<HashSet<_>>()
+ .len()
+ == group_expr_size)
+ }
Review Comment:
A bool flag may be better.
```rust
pub strct Aggregate {
/// The incoming logical plan
pub input: Arc<LogicalPlan>,
/// Grouping expressions
pub group_expr: Vec<Expr>,
...
is_distinct: bool,
}
```
--
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]