Skip to content

Commit 60b9af3

Browse files
Include match statement inline of checking the limit
1 parent c0eb690 commit 60b9af3

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,14 @@ trait CheckAnalysis extends PredicateHelper {
6868
case e if e.dataType != IntegerType => failAnalysis(
6969
s"The limit expression must be integer type, but got " +
7070
e.dataType.catalogString)
71-
case _ => // OK
72-
}
73-
74-
val evalledExpression = limitExpr.eval()
75-
76-
evalledExpression match {
77-
case null => failAnalysis(
78-
"The evaluated limit expression must not be null, but got " +
79-
limitExpr.sql)
80-
case e if e.asInstanceOf[Int] < 0 => failAnalysis(
81-
"The limit expression must be equal to or greater than 0, but got " +
82-
e.asInstanceOf[Int])
83-
case e => // OK
71+
case e =>
72+
e.eval() match {
73+
case null => failAnalysis(
74+
s"The evaluated limit expression must not be null, but got ${limitExpr.sql}")
75+
case v: Int if v < 0 => failAnalysis(
76+
s"The limit expression must be equal to or greater than 0, but got $v")
77+
case _ => // OK
78+
}
8479
}
8580
}
8681

0 commit comments

Comments
 (0)