turboFei commented on a change in pull request #27151: [SPARK-26218][Follow up] 
Fix the corner case when casting float to Integer.
URL: https://github.com/apache/spark/pull/27151#discussion_r364828646
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/types/numerics.scala
 ##########
 @@ -121,8 +121,8 @@ object FloatExactNumeric extends FloatIsFractional {
   private def overflowException(x: Float, dataType: String) =
     throw new ArithmeticException(s"Casting $x to $dataType causes overflow")
 
-  private val intUpperBound = Int.MaxValue.toFloat
-  private val intLowerBound = Int.MinValue.toFloat
+  private val intUpperBound = Int.MaxValue
 
 Review comment:
   As mentioned by cloud-fan, it seems that cast int to float, then cast to 
double is not same with casting it to double directly.
   
![image](https://user-images.githubusercontent.com/6757692/72084214-0e5a2880-333e-11ea-820d-dc4172d93986.png)
   

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