Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/17432#discussion_r108074254
--- 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 --
Why would I want to do that? I want to prevent that the optimizer collapses
two adjacent windows that are dependent, so I just need to check if the outer
window does not reference the inner window; `windowOutputSet` does exactly
this. Am I missing something?
---
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]