You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "vladimirg-db (via GitHub)" <gi...@apache.org> on 2024/08/15 16:22:40 UTC

[PR] [SPARK-49250][SQL] Improve error message for nested UnresolvedWindowExpression in CheckAnalysis [spark]

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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49250][SQL] Improve error message for nested UnresolvedWindowExpression in CheckAnalysis [spark]

Posted by "vladimirg-db (via GitHub)" <gi...@apache.org>.
vladimirg-db commented on code in PR #47775:
URL: https://github.com/apache/spark/pull/47775#discussion_r1718652498


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala:
##########
@@ -305,6 +305,9 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog with QueryErrorsB
               throw QueryCompilationErrors.invalidStarUsageError(operator.nodeName, Seq(s))
             }
 
+          case UnresolvedWindowExpression(_, WindowSpecReference(windowName)) =>

Review Comment:
   @cloud-fan I am reluctant to remove the existing `UnresolvedWindowExpression` checks to avoid correctness issues.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49250][SQL] Improve error message for nested UnresolvedWindowExpression in CheckAnalysis [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #47775: [SPARK-49250][SQL] Improve error message for nested UnresolvedWindowExpression in CheckAnalysis
URL: https://github.com/apache/spark/pull/47775


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-49250][SQL] Improve error message for nested UnresolvedWindowExpression in CheckAnalysis [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #47775:
URL: https://github.com/apache/spark/pull/47775#issuecomment-2293830463

   thanks, merging to master!


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org