-
- Downloads
[SPARK-13806] [SQL] fix rounding mode of negative float/double
## What changes were proposed in this pull request? Round() in database usually round the number up (away from zero), it's different than Math.round() in Java. For example: ``` scala> java.lang.Math.round(-3.5) res3: Long = -3 ``` In Database, we should return -4.0 in this cases. This PR remove the buggy special case for scale=0. ## How was this patch tested? Add tests for negative values with tie. Author: Davies Liu <davies@databricks.com> Closes #11894 from davies/fix_round.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala 15 additions, 33 deletions...ache/spark/sql/catalyst/expressions/mathExpressions.scala
- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MathFunctionsSuite.scala 4 additions, 0 deletions...e/spark/sql/catalyst/expressions/MathFunctionsSuite.scala
Please register or sign in to comment