Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/5838#discussion_r29964909
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
@@ -172,6 +172,11 @@ object ColumnPruning extends Rule[LogicalPlan] {
case Project(projectList, Limit(exp, child)) =>
Limit(exp, Project(projectList, child))
+
+ // push down project if possible when the child is sort
+ case p @ Project(projectList, s @ Sort(order, _, grandChild))
+ if (s.references -- p.outputSet).isEmpty =>
--- End diff --
You don't need `order` here, and with that removed you might be able to put
the `if` on the same line. Otherwise I think the if should be indented 4
characters.
Also, consider `s.references.subsetOf(p.outputSet)`, which more clearly
says "the `Sort` can be evaluated with `output` of the `Project`" to me.
---
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]