Blizzara commented on code in PR #14553:
URL: https://github.com/apache/datafusion/pull/14553#discussion_r1952817778


##########
datafusion/expr/src/logical_plan/builder.rs:
##########
@@ -1090,11 +1090,31 @@ impl LogicalPlanBuilder {
         group_expr: impl IntoIterator<Item = impl Into<Expr>>,
         aggr_expr: impl IntoIterator<Item = impl Into<Expr>>,
     ) -> Result<Self> {
-        let group_expr = normalize_cols(group_expr, &self.plan)?;
+        self._aggregate(group_expr, aggr_expr, true)
+    }
+
+    pub fn aggregate_without_implicit_group_by_exprs(
+        self,
+        group_expr: impl IntoIterator<Item = impl Into<Expr>>,
+        aggr_expr: impl IntoIterator<Item = impl Into<Expr>>,
+    ) -> Result<Self> {
+        self._aggregate(group_expr, aggr_expr, false)
+    }
+
+    fn _aggregate(
+        self,
+        group_expr: impl IntoIterator<Item = impl Into<Expr>>,
+        aggr_expr: impl IntoIterator<Item = impl Into<Expr>>,
+        include_implicit_group_by_exprs: bool,
+    ) -> Result<Self> {
+        let mut group_expr = normalize_cols(group_expr, &self.plan)?;
         let aggr_expr = normalize_cols(aggr_expr, &self.plan)?;
 
-        let group_expr =
-            add_group_by_exprs_from_dependencies(group_expr, 
self.plan.schema())?;
+        if include_implicit_group_by_exprs {
+            group_expr =
+                add_group_by_exprs_from_dependencies(group_expr, 
self.plan.schema())?;
+        }

Review Comment:
   nit: style-wise I'd prefer keeping `group_expr` non-mut and doing something 
like:
   ```suggestion
           let group_expr = if include_implicit_group_by_exprs {
               group_expr =
                   add_group_by_exprs_from_dependencies(group_expr, 
self.plan.schema())?;
           } else {
              group_exrp
           };
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to