gengliangwang commented on a change in pull request #32686: URL: https://github.com/apache/spark/pull/32686#discussion_r642492873
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ########## @@ -423,7 +424,9 @@ class Analyzer(override val catalogManager: CatalogManager) */ object ResolveAliases extends Rule[LogicalPlan] { private def assignAliases(exprs: Seq[NamedExpression]) = { - exprs.map(_.transformUp { case u @ UnresolvedAlias(child, optGenAliasFunc) => + exprs.map(_.transformUpWithPruning(_.containsPattern(UNRESOLVED_ALIAS)) + { Review comment: Nit: the indention looks wired here. Shall we move the `{` in the above line? ########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ########## @@ -3736,7 +3744,8 @@ object EliminateUnions extends Rule[LogicalPlan] { * rule can't work for those parameters. */ object CleanupAliases extends Rule[LogicalPlan] with AliasHelper { - override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUp { + override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUpWithPruning( + _.containsPattern(ALIAS)) { Review comment: It seems that we need to set the Tree Pattern of `MultiAlias`. ########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ########## @@ -1876,7 +1879,7 @@ class Analyzer(override val catalogManager: CatalogManager) private def allowGroupByAlias: Boolean = conf.groupByAliases && !conf.ansiEnabled override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUpWithPruning( - AlwaysProcess.fn, ruleId) { + _.containsAllPatterns(AGGREGATE, UNRESOLVED_ATTRIBUTE), ruleId) { Review comment: Let's add comment saying that `mayResolveAttrByAggregateExprs` requires the TreePattern `UNRESOLVED_ATTRIBUTE` ########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/interfaces.scala ########## @@ -117,6 +120,7 @@ case class AggregateExpression( UnresolvedAttribute(aggregateFunction.toString) } + Review comment: Unnecessary change. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org