cloud-fan commented on code in PR #42778:
URL: https://github.com/apache/spark/pull/42778#discussion_r1315322373


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -1305,11 +1305,20 @@ object TransposeWindow extends Rule[LogicalPlan] {
     }
   }
 
+  // Returns false if the parent 'w1' window function order by any of the 
window
+  // expressions produced by 'w2'.
+  private def compatibleOrderBy(w1: Window, w2: Window): Boolean = {
+    val childWindowExprs = w2.windowExpressions.map(x => x.toAttribute)
+    val parentOrder = w1.orderSpec.flatMap(x => x.references)
+    childWindowExprs.intersect(parentOrder).isEmpty
+  }
+
   private def windowsCompatible(w1: Window, w2: Window): Boolean = {
     w1.references.intersect(w2.windowOutputSet).isEmpty &&

Review Comment:
   no, the `Window` operator won't exclude C, as it only excludes 
`windowOutputSet`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to