maropu commented on a change in pull request #25300: [SPARK-28503][SQL] Return 
null result on cast an out-of-range value to a integral type
URL: https://github.com/apache/spark/pull/25300#discussion_r309969719
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 ##########
 @@ -442,8 +443,38 @@ case class Cast(child: Expression, dataType: DataType, 
timeZoneId: Option[String
       buildCast[Int](_, d => null)
     case TimestampType =>
       buildCast[Long](_, t => timestampToLong(t))
-    case x: NumericType =>
-      b => x.numeric.asInstanceOf[Numeric[Any]].toLong(b)
+    case ByteType =>
+      b => b.asInstanceOf[Byte].toLong
+    case ShortType =>
+      b => b.asInstanceOf[Short].toLong
+    case IntegerType =>
+      b => b.asInstanceOf[Int].toLong
 
 Review comment:
   Ur, I see. Good idea to ask the JVM guys, hahaha

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to