You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/04/14 04:24:50 UTC
[GitHub] [spark] cloud-fan commented on a diff in pull request #35975: [SPARK-28330][SQL] Support ANSI SQL: result offset clause in query expression
cloud-fan commented on code in PR #35975:
URL: https://github.com/apache/spark/pull/35975#discussion_r850071855
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala:
##########
@@ -411,10 +411,34 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog {
case GlobalLimit(limitExpr, _) => checkLimitLikeClause("limit", limitExpr)
- case LocalLimit(limitExpr, _) => checkLimitLikeClause("limit", limitExpr)
+ case LocalLimit(limitExpr, child) =>
+ checkLimitLikeClause("limit", limitExpr)
+ child match {
+ case Offset(offsetExpr, _) =>
+ val limit = limitExpr.eval().asInstanceOf[Int]
+ val offset = offsetExpr.eval().asInstanceOf[Int]
+ if (Int.MaxValue - limit < offset) {
+ failAnalysis(
+ s"""
+ |The sum of the LIMIT clause and the OFFSET clause must not be greater than
+ |the maximum 32-bit integer value (2,147,483,647),
+ |but found limit = $limit, offset = $offset.
+ |""".stripMargin.replace("\n", " "))
+ }
+ case _ =>
+ }
+
+ case Offset(offsetExpr, _) => checkLimitLikeClause("offset", offsetExpr)
case Tail(limitExpr, _) => checkLimitLikeClause("tail", limitExpr)
+ case o if !o.isInstanceOf[GlobalLimit] && !o.isInstanceOf[LocalLimit]
Review Comment:
Can we move this check to `checkOutermostOffset` and rename it to `checkOffsetOperator`? It's better to have a central place to check offset position.
--
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