Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/11565#discussion_r55630583
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
@@ -326,9 +326,9 @@ object ColumnPruning extends Rule[LogicalPlan] {
case p @ Project(_, a: Aggregate) if (a.outputSet --
p.references).nonEmpty =>
p.copy(
child = a.copy(aggregateExpressions =
a.aggregateExpressions.filter(p.references.contains)))
- case p @ Project(_, w: Window) if (w.outputSet --
p.references).nonEmpty =>
+ case p @ Project(_, w: Window)
+ if (AttributeSet(w.windowExpressions.map(_.toAttribute)) --
p.references).nonEmpty =>
--- End diff --
the condition looks pretty complex now, how about we combine this case and
the last case(`case p @ Project(_, child) =>`)? e.g.:
```
case p @ Project(_, w: Window) if (w.outputSet -- p.references).nonEmpty =>
val newWindowExprs = w.windowExpressions.filter(p.references.contains)
val newGrandChild = prunedChild(child,
AttributeSet(newWindowExprs.flatMap(_.references)))
p.copy(child = w.copy(
windowExpressions = newWindowExprs,
child = newGrandChild))
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]