wangyum commented on a change in pull request #35214: URL: https://github.com/apache/spark/pull/35214#discussion_r787589420
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala ########## @@ -1322,6 +1322,12 @@ object CombineUnions extends Rule[LogicalPlan] { case Union(children, byName, allowMissingCol) if byName == topByName && allowMissingCol == topAllowMissingCol => stack.pushAll(children.reverse) + case Project(projectList, Distinct(u @ Union(children, byName, allowMissingCol))) + if projectList.forall(_.deterministic) && children.nonEmpty && + flattenDistinct && byName == topByName && allowMissingCol == topAllowMissingCol => + val newChildren = PushProjectionThroughUnion.pushProjectionThroughUnion(projectList, u) + .map(CollapseProject(_)) Review comment: Another attempt combine unions after `ReplaceDistinctWithAggregate`: https://github.com/apache/spark/pull/35249 -- 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-unsubscr...@spark.apache.org 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