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

    https://github.com/apache/spark/pull/17432#discussion_r108086367
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -597,12 +597,14 @@ object CollapseRepartition extends Rule[LogicalPlan] {
     
     /**
      * Collapse Adjacent Window Expression.
    - * - If the partition specs and order specs are the same, collapse into 
the parent.
    + * - If the partition specs and order specs are the same and the window 
expression are
    + *   independent, collapse into the parent.
      */
     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 == ps2 && os1 == os2 =>
    -      w.copy(windowExpressions = we2 ++ we1, child = grandChild)
    +    case w1 @ Window(we1, ps1, os1, w2 @ Window(we2, ps2, os2, grandChild))
    +        if ps1 == ps2 && os1 == os2 && 
w1.references.intersect(w2.windowOutputSet).isEmpty =>
    --- End diff --
    
    uh... nvm.  I added the extra logics to collapse `Project` into `Window` in 
my private branch. That is why the `windowOutputSet ` in my branch has the 
extra attributes that are from `Project`. 


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