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

 ##########
 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:
   it's true
   ```
   scala> Int.MaxValue.toDouble
   res2: Double = 2.147483647E9
   
   scala> Int.MaxValue.toFloat.toDouble
   res3: Double = 2.147483648E9
   ```

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