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/10/28 05:31:22 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_r147546887
  
    --- 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))
    --- End diff --
    
    Just to ensure the results are still the same with and without the rule. 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org