alamb commented on code in PR #8038:
URL: https://github.com/apache/arrow-datafusion/pull/8038#discussion_r1387179094
##########
datafusion/physical-plan/src/aggregates/mod.rs:
##########
@@ -800,6 +807,39 @@ impl AggregateExec {
pub fn group_by(&self) -> &PhysicalGroupBy {
&self.group_by
}
+
+ /// true, if this Aggregate has a group-by with no required or explicit
ordering,
+ /// no filtering and no aggregate expressions
+ /// This method qualifies the use of the LimitedDistinctAggregation
rewrite rule
+ /// on an AggregateExec.
+ pub fn is_unordered_unfiltered_group_by_distinct(&self) -> bool {
+ // ensure there is a group by
+ if self.group_by().is_empty() {
+ return false;
+ }
+ // ensure there are no aggregate expressions
+ if !self.aggr_expr().is_empty() {
+ return false;
+ }
+ // ensure there are no filters on aggregate expressions; the above
check
+ // may preclude this case
+ if self.filter_expr().iter().any(|e| e.is_some()) {
+ return false;
+ }
+ // ensure there are no order by expressions
+ if self.order_by_expr().iter().any(|e| e.is_some()) {
+ return false;
+ }
+ // ensure there is no output ordering; can this rule be relaxed?
Review Comment:
yes I think keeping the check is quite prudent
--
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]