vladimirg-db opened a new pull request, #50769: URL: https://github.com/apache/spark/pull/50769
### What changes were proposed in this pull request? Correctly resolve names in HAVING and ORDER BY in single-pass Analyzer. In case we are resolving those expression trees on top of an `Aggregate`, we can naturally only access attributes which are directly outputted from the `Aggregate` (main output), or if they are present in `Aggregate`'s grouping expressions (hidden output). However, we can actually access any attributes from hidden output if we are resolving an `AggregateExpression` in ORDER BY or HAVING. This `AggregateExpression` will later be pushed down to `Aggregate` by `SortResolver`. This query fails, because "col2" is not present in grouping expressions and is not present in `Aggregate`'s output: `SELECT COUNT(col1) FROM VALUES (1, 2) GROUP BY col1 ORDER BY MAX(col2);` This query succeeds, because we are resolving "col2" under `MAX`: `SELECT COUNT(col1) FROM VALUES (1, 2) GROUP BY col1 ORDER BY MAX(col2);` ### Why are the changes needed? This improves name resolution in the new single-pass Analyzer. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing tests. ### Was this patch authored or co-authored using generative AI tooling? copilot.nvim. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org