You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/06/30 05:32:20 UTC
[GitHub] spark pull request #17899: [SPARK-20636] Add new optimization rule to transp...
Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/17899#discussion_r124966455
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala ---
@@ -610,6 +611,25 @@ object CollapseWindow extends Rule[LogicalPlan] {
}
/**
+ * Transpose Adjacent Window Expressions.
+ * - If the partition spec of the parent Window expression is compatible with the partition spec
+ * of the child window expression, transpose them.
+ */
+object TransposeWindow extends Rule[LogicalPlan] {
+ private def compatibleParititions(ps1 : Seq[Expression], ps2: Seq[Expression]): Boolean = {
+ ps1.length < ps2.length && ps2.take(ps1.length).permutations.exists(ps1.zip(_).forall {
+ case (l, r) => l.semanticEquals(r)
+ })
+ }
+
+ def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {
+ case w1 @ Window(we1, ps1, os1, w2 @ Window(we2, ps2, os2, grandChild))
+ if w1.references.intersect(w2.windowOutputSet).isEmpty && compatibleParititions(ps1, ps2) =>
--- End diff --
No test case covers the condition `w1.references.intersect(w2.windowOutputSet).isEmpty`
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org