minyyy commented on code in PR #35864:
URL: https://github.com/apache/spark/pull/35864#discussion_r845586689
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -831,8 +831,16 @@ object ColumnPruning extends Rule[LogicalPlan] {
e.copy(child = prunedChild(child, e.references))
// prune unrequired references
- case p @ Project(_, g: Generate) if p.references != g.outputSet =>
- val requiredAttrs = p.references -- g.producedAttributes ++
g.generator.references
+ // There are 2 types of pruning here:
+ // 1. For attributes in g.child.outputSet that is not used by the
generator nor the project,
+ // we directly remove it from the output list of g.child.
+ // 2. For attributes that is not used by the project but it is used by the
generator, we put
+ // it in g.unrequiredChildIndex to save memory usage.
+ case p @ Project(_, g: Generate) if g.child.output.zipWithIndex.exists(
+ pair =>
+ !p.references.contains(pair._1) &&
+ (!g.generator.references.contains(pair._1) ||
!g.unrequiredChildIndex.contains(pair._2))) =>
Review Comment:
It is fixed in the latest implementation, I will mark it as resolved.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]