vladimirg-db opened a new pull request, #47775: URL: https://github.com/apache/spark/pull/47775
### What changes were proposed in this pull request? When CheckAnalysis encounters `UnresolvedWindowExpression` in `Project` or `Aggregate`, it throws `QueryCompilationErrors.windowSpecificationNotDefinedError`: - https://github.com/apache/spark/commit/4718d59c6c4 - https://github.com/apache/spark/commit/0b48d3f61b7 However, consider the following query: `SELECT (SUM(col1) OVER(unspecified_window) / 1) FROM VALUES (1)`. Here `UnreolvedWindowExpression` is wrapped into the division expression. And `CheckAnalysis` throws a different unrelated `org.apache.spark.sql.catalyst.analysis.UnresolvedException: [INTERNAL_ERROR] Invalid call to dataType on unresolved object SQLSTATE: XX000` exception earlier from this [case](https://github.com/apache/spark/blob/0b48d3f61b726209e96b0b967530534b5ad9101d/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala#L308). The solution to improve this would be to match `UnreolvedWindowExpression` early. ### Why are the changes needed? To improve error message for incorrect window usage. ### Does this PR introduce _any_ user-facing change? Yes, the error message is better now ### How was this patch tested? Added a unit test ### Was this patch authored or co-authored using generative AI tooling? No -- 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]
