Skip to content

Commit 3c402d3

Browse files
committed
address comments
1 parent bdf4e56 commit 3c402d3

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ trait CheckAnalysis extends PredicateHelper {
4646
}).length > 1
4747
}
4848

49+
private def checkLimitClause(limitExpr: Expression): Unit = {
50+
val numRows = limitExpr.eval().asInstanceOf[Int]
51+
if (numRows < 0) {
52+
failAnalysis(
53+
s"number_rows in limit clause must be equal to or greater than 0. " +
54+
s"number_rows:$numRows")
55+
}
56+
}
57+
4958
def checkAnalysis(plan: LogicalPlan): Unit = {
5059
// We transform up and order the rules so as to catch the first possible failure instead
5160
// of the result of cascading resolution failures.
@@ -251,21 +260,9 @@ trait CheckAnalysis extends PredicateHelper {
251260
s"but one table has '${firstError.output.length}' columns and another table has " +
252261
s"'${s.children.head.output.length}' columns")
253262

254-
case l: GlobalLimit =>
255-
val numRows = l.limitExpr.eval().asInstanceOf[Int]
256-
if (numRows < 0) {
257-
failAnalysis(
258-
s"number_rows in limit clause must be equal to or greater than 0. " +
259-
s"number_rows:$numRows")
260-
}
263+
case GlobalLimit(limitExpr, _) => checkLimitClause(limitExpr)
261264

262-
case l: LocalLimit =>
263-
val numRows = l.limitExpr.eval().asInstanceOf[Int]
264-
if (numRows < 0) {
265-
failAnalysis(
266-
s"number_rows in limit clause must be equal to or greater than 0. " +
267-
s"number_rows:$numRows")
268-
}
265+
case LocalLimit(limitExpr, _) => checkLimitClause(limitExpr)
269266

270267
case p if p.expressions.exists(ScalarSubquery.hasCorrelatedScalarSubquery) =>
271268
p match {

0 commit comments

Comments
 (0)