vladimirg-db commented on code in PR #60090:
URL: https://github.com/apache/spark/pull/60090#discussion_r4467431290


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -3860,6 +3860,24 @@ class Analyzer(
       Project(windowOps.output ++ newExpressionsWithWindowFunctions, windowOps)
     } // end of addWindow
 
+    /**
+     * Extracts all nested window expressions and places the HAVING filter 
below every Window.
+     */
+    private def addWindowWithHaving(

Review Comment:
   I think we need a flag to fall back to the old behavior



##########
sql/core/src/test/resources/sql-tests/inputs/window-resolution-edge-cases.sql:
##########
@@ -99,6 +99,16 @@ SELECT col1, MAX(ROW_NUMBER() OVER w) OVER () AS max_rn FROM 
t1 WINDOW w AS (ORD
 
 -- Nested windows over an aggregate, and in QUALIFY together with HAVING.
 SELECT col1, MAX(RANK() OVER (ORDER BY SUM(col2))) OVER () AS m FROM t1 GROUP 
BY col1;
+
+-- HAVING must be evaluated before every nested window layer.
+SELECT

Review Comment:
   How about some other cases? with generator, lca, etc



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