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 2021/03/26 15:12:36 UTC

[GitHub] [spark] yaooqinn commented on a change in pull request #31971: [SPARK-34744][SQL] Improve error message for casting cause overflow error

yaooqinn commented on a change in pull request #31971:
URL: https://github.com/apache/spark/pull/31971#discussion_r602372126



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala
##########
@@ -1698,10 +1698,18 @@ class CastSuite extends CastSuiteBase {
 
   test("SPARK-34744: Improve error message for casting cause overflow error") {
     withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
-      val e = intercept[ArithmeticException] {
-        Cast(Literal(128), ByteType).eval()
+      val e1 = intercept[ArithmeticException] {
+        Cast(Literal(Byte.MaxValue.toInt + 1), ByteType).eval()
       }.getMessage
-      assert(e.contains("Casting 128 to tinyint causes overflow"))
+      assert(e1.contains("Casting 128 to tinyint causes overflow"))
+      val e2 = intercept[ArithmeticException] {
+        Cast(Literal(Short.MaxValue.toInt + 1), ShortType).eval()

Review comment:
       nit: redundant toInt




-- 
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.

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