cloud-fan commented on code in PR #49955: URL: https://github.com/apache/spark/pull/49955#discussion_r1980957725
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala: ########## @@ -1032,6 +1044,42 @@ object ColumnPruning extends Rule[LogicalPlan] { p } + case p @ Project(_, ul: UnionLoop) => + if (!ul.outputSet.subsetOf(p.references)) { + val newAnchorChildProj = prunedChild(ul.anchor, p.references) + val neededIndicesListRef = { Review Comment: can you briefly describe the logic here? I thought we could follow how Union is handled ``` val anchor = ul.anchor val newAnchor = prunedChild(anchor, p.references) val newOutput = newAnchor.output val selected = ul.recursion.output.zipWithIndex.filter { case (a, i) => newOutput.contains(anchor.output(i)) }.map(_._1) val newRecursion = Project(selected, ul.recursion) p.copy(child = ul.withNewChildren(Seq(newAnchor, newRecursion))) ``` -- 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