Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15317#discussion_r81433195
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -538,6 +539,19 @@ object CollapseRepartition extends Rule[LogicalPlan] {
     }
     
     /**
    + * Collapse Adjacent Window Expression.
    + * - Collapse only if they have the same partition specs and order specs.
    + */
    +object CollapseWindow extends Rule[LogicalPlan] {
    +  def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {
    +    case w @ Window(we1, ps1, os1, Window(we2, ps2, os2, grandChild))
    +        if ps1.equals(ps2) && os1.equals(os2) =>
    --- End diff --
    
    `equals`? That is only needed in Java, `==` is the same in Scala.
    
    You can be a bit more lenient with respect to the sort order. The sort 
order of the window collapsed window must be match the prefix of the window in 
which it is collapsed, for instance a window with sort order `a desc`, can be 
collapsed into a window with sort order `a desc`, `b asc`.
    
    Note that if we widen the ordering constraint, then we should also support 
the inverse case, by collapsing the parent window in to the child window.


---
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]

Reply via email to