thinkharderdev commented on code in PR #2716:
URL: https://github.com/apache/arrow-datafusion/pull/2716#discussion_r895161026


##########
datafusion/expr/src/expr.rs:
##########
@@ -270,6 +270,27 @@ pub enum GroupingSet {
     GroupingSets(Vec<Vec<Expr>>),
 }
 
+impl GroupingSet {
+    /// Return all distinct exprs in the grouping set. For `CUBE` and `ROLLUP` 
this
+    /// is just the underlying list of exprs. For `GROUPING SET` we need to 
deduplicate
+    /// the exprs in the underlying sets.
+    pub fn distinct_expr(&self) -> Vec<Expr> {
+        match self {
+            GroupingSet::Rollup(exprs) => exprs.clone(),
+            GroupingSet::Cube(exprs) => exprs.clone(),
+            GroupingSet::GroupingSets(groups) => {
+                let mut exprs: Vec<Expr> = vec![];
+                for exp in groups.iter().flatten() {
+                    if !exprs.contains(exp) {

Review Comment:
   Yeah, this is unfortunate 



-- 
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]

Reply via email to