wangyum commented on a change in pull request #35214: URL: https://github.com/apache/spark/pull/35214#discussion_r786417364
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala ########## @@ -762,22 +762,22 @@ object PushProjectionThroughUnion extends Rule[LogicalPlan] with PredicateHelper result.asInstanceOf[A] } + def pushProjectionThroughUnion(projectList: Seq[NamedExpression], u: Union): Seq[LogicalPlan] = { + val newFirstChild = Project(projectList, u.children.head) + val newOtherChildren = u.children.tail.map { child => + val rewrites = buildRewrites(u.children.head, child) + Project(projectList.map(pushToRight(_, rewrites)), child) + } + newFirstChild +: newOtherChildren + } + def apply(plan: LogicalPlan): LogicalPlan = plan.transformWithPruning( _.containsAllPatterns(UNION, PROJECT)) { // Push down deterministic projection through UNION ALL - case p @ Project(projectList, u: Union) => Review comment: `CombineUnions` need it to push down projection https://github.com/apache/spark/pull/35214/files#diff-11264d807efa58054cca2d220aae8fba644ee0f0f2a4722c46d52828394846efR1328 -- 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