You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/01/17 07:39:59 UTC
[GitHub] [spark] cloud-fan commented on a change in pull request #35214: [SPARK-37915][SQL] Push down deterministic projection through SQL UNION and combine them
cloud-fan commented on a change in pull request #35214:
URL: https://github.com/apache/spark/pull/35214#discussion_r785702146
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -766,18 +767,24 @@ object PushProjectionThroughUnion extends Rule[LogicalPlan] with PredicateHelper
_.containsAllPatterns(UNION, PROJECT)) {
// Push down deterministic projection through UNION ALL
- case p @ Project(projectList, u: Union) =>
+ case Project(projectList, u: Union) if projectList.forall(_.deterministic) =>
assert(u.children.nonEmpty)
- if (projectList.forall(_.deterministic)) {
- 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)
- }
- u.copy(children = newFirstChild +: newOtherChildren)
- } else {
- p
+ 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)
+ }
+ u.copy(children = newFirstChild +: newOtherChildren)
+
+ // Push down deterministic projection through SQL UNION
+ case Project(projectList, Distinct(u: Union)) if projectList.forall(_.deterministic) =>
Review comment:
hmm, how does this help eliminate aggregates?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org