vladimirg-db opened a new pull request, #57704:
URL: https://github.com/apache/spark/pull/57704

   ### What changes were proposed in this pull request?
   
   Place a resolved HAVING filter below the complete Window chain when 
generator extraction has
   inserted Project and Generate operators above it. If the condition's 
attributes are not available
   below every Window, retain the existing fallback placement.
   
   Add regression coverage for HAVING conditions on grouping columns and 
aggregate aliases, including
   multiple window specifications, and document the corrected behavior in the 
SQL migration guide.
   
   
   ### Why are the changes needed?
   
   Generator extraction can hide the Window chain from the analyzer's normal 
HAVING handling. The
   remaining fallback then places HAVING above Window, so window functions see 
groups that HAVING
   removes.
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Window functions are now evaluated after HAVING for queries that also 
select generators. For
   example, the window count from this query changes from 4 to the correct 
value 3:
   
   ```sql
   SELECT explode(array(a)), count(*) OVER (), a
   FROM VALUES (1), (2), (3), (NULL) AS t(a)
   GROUP BY a
   HAVING a IS NOT NULL;
   ```
   
   
   ### How was this patch tested?
   
   Added regression tests and ran:
   
   ```
   build/sbt 'sql/testOnly org.apache.spark.sql.GeneratorFunctionSuite'
   ```
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (GPT-5)
   


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