punya commented on code in PR #27682:
URL: https://github.com/apache/datafusion/pull/27682#discussion_r4735299985


##########
datafusion/sql/src/query.rs:
##########
@@ -312,43 +308,43 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
         }
     }
 
-    /// Handle AGGREGATE pipe operator
+    /// Plans `|> AGGREGATE a GROUP BY g` as `SELECT g, a GROUP BY g`, ordered
+    /// by the items that have an ordering suffix, grouping items first
     fn pipe_operator_aggregate(
         &self,
         plan: LogicalPlan,
         full_table_exprs: Vec<ExprWithAliasAndOrderBy>,
         group_by_expr: Vec<ExprWithAliasAndOrderBy>,
         planner_context: &mut PlannerContext,
     ) -> Result<LogicalPlan> {
-        let plan_schema = plan.schema();
-        let process_expr =
-            |expr_with_alias_and_order_by: ExprWithAliasAndOrderBy,
-             planner_context: &mut PlannerContext| {
-                let expr_with_alias = expr_with_alias_and_order_by.expr;
-                let sql_expr = expr_with_alias.expr;
-                let alias = expr_with_alias.alias;
-
-                let df_expr = self.sql_to_expr(sql_expr, plan_schema, 
planner_context)?;
-
-                match alias {
-                    Some(alias_ident) => 
df_expr.alias_if_changed(alias_ident.value),
-                    None => Ok(df_expr),
-                }
-            };
-
-        let aggr_exprs: Vec<Expr> = full_table_exprs
-            .into_iter()
-            .map(|e| process_expr(e, planner_context))
-            .collect::<Result<Vec<_>>>()?;
-
-        let group_by_exprs: Vec<Expr> = group_by_expr
+        let group_by = group_by_expr
+            .iter()
+            .map(|item| item.expr.expr.clone())
+            .collect();

Review Comment:
   Great catch, thanks! I think it would be clearest (I.e. least surprising) if 
we reject literals instead of silently interpreting them as constants.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to