You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zml1206 (via GitHub)" <gi...@apache.org> on 2023/08/17 16:48:24 UTC

[GitHub] [spark] zml1206 commented on a diff in pull request #42531: [SPARK-44846][SQL] PushFoldableIntoBranches in complex grouping expressions may cause bi…

zml1206 commented on code in PR #42531:
URL: https://github.com/apache/spark/pull/42531#discussion_r1297486130


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -644,6 +644,8 @@ object PushFoldableIntoBranches extends Rule[LogicalPlan] {
 
   def apply(plan: LogicalPlan): LogicalPlan = plan.transformWithPruning(
     _.containsAnyPattern(CASE_WHEN, IF), ruleId) {
+    case a @ Aggregate(groupingExpressions, _, _)
+      if !groupingExpressions.forall(_.isInstanceOf[NamedExpression]) => a

Review Comment:
   Thanks. In `PhysicalAggregation`,if the expression is not a NamedExpressions, it add an alias. Also I'm not sure if complex expressions are generated anywhere else other than `RemoveRedundantAggregates`. So is it safer to fix `PushFoldableIntoBranches`, and the impact is smaller?



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -644,6 +644,8 @@ object PushFoldableIntoBranches extends Rule[LogicalPlan] {
 
   def apply(plan: LogicalPlan): LogicalPlan = plan.transformWithPruning(
     _.containsAnyPattern(CASE_WHEN, IF), ruleId) {
+    case a @ Aggregate(groupingExpressions, _, _)
+      if !groupingExpressions.forall(_.isInstanceOf[NamedExpression]) => a

Review Comment:
   Thanks. In `PhysicalAggregation`,if the expression is not a NamedExpressions, it add an alias. Also I'm not sure if complex expressions are generated anywhere else other than `RemoveRedundantAggregates`. So is it safer to fix `PushFoldableIntoBranches`, and the impact is smaller?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org