Skip to content

Commit 926e9c4

Browse files
sameeragarwalyhuai
authored andcommitted
[SPARK-13760][SQL] Fix BigDecimal constructor for FloatType
## What changes were proposed in this pull request? A very minor change for using `BigDecimal.decimal(f: Float)` instead of `BigDecimal(f: float)`. The latter is deprecated and can result in inconsistencies due to an implicit conversion to `Double`. ## How was this patch tested? N/A cc yhuai Author: Sameer Agarwal <[email protected]> Closes #11597 from sameeragarwal/bigdecimal.
1 parent a4a0add commit 926e9c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ case class Round(child: Expression, scale: Expression)
748748
if (f.isNaN || f.isInfinite) {
749749
f
750750
} else {
751-
BigDecimal(f).setScale(_scale, HALF_UP).toFloat
751+
BigDecimal.decimal(f).setScale(_scale, HALF_UP).toFloat
752752
}
753753
case DoubleType =>
754754
val d = input1.asInstanceOf[Double]

0 commit comments

Comments
 (0)