shivadarshan-devadiga commented on code in PR #60749:
URL: https://github.com/apache/spark/pull/60749#discussion_r4642341376


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -4394,6 +4403,17 @@ class Analyzer(
         (resolved, other)
     }
 
+    /**
+     * The attributes defined by the Window nodes of this query block below 
`plan`, which
+     * ExtractWindowExpressions creates for the window functions of the SELECT 
list.
+     */
+    private def windowOutputs(plan: LogicalPlan): AttributeSet = plan match {
+      case w: Window => w.windowOutputSet ++ windowOutputs(w.child)
+      case p: Project => windowOutputs(p.child)

Review Comment:
   It stops there on purpose. The `Window` nodes of the SELECT list are above 
the `Aggregate`, and below it is the input of the aggregation. Aliases of 
aggregates aren't window outputs, so `resolveQualifyCondition` still resolves 
them as before. After `GROUP BY`, the input columns that aren't grouped can't 
be referenced anyway. The `SUM(b) AS b ... GROUP BY a QUALIFY b > 2` query in 
`qualify.sql` checks that the alias still resolves. I added a sentence to the 
doc comment about where the windows are.



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