File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
main/scala/org/apache/spark/sql/types
test/scala/org/apache/spark/sql/types/decimal Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ final class Decimal extends Ordered[Decimal] with Serializable {
8686 if (precision < 19 ) {
8787 return null // Requested precision is too low to represent this value
8888 }
89- this .decimalVal = BigDecimal (longVal )
89+ this .decimalVal = BigDecimal (unscaled )
9090 this .longVal = 0L
9191 } else {
9292 val p = POW_10 (math.min(precision, MAX_LONG_DIGITS ))
Original file line number Diff line number Diff line change @@ -156,4 +156,10 @@ class DecimalSuite extends SparkFunSuite with PrivateMethodTester {
156156 assert(Decimal (- 100 ) % Decimal (3 ) === Decimal (- 1 ))
157157 assert(Decimal (100 ) % Decimal (0 ) === null )
158158 }
159+
160+ test(" set/setOrNull" ) {
161+ assert(new Decimal ().set(10L , 10 , 0 ).toUnscaledLong === 10L )
162+ assert(new Decimal ().set(100L , 10 , 0 ).toUnscaledLong === 100L )
163+ assert(Decimal (Long .MaxValue , 100 , 0 ).toUnscaledLong === Long .MaxValue )
164+ }
159165}
You can’t perform that action at this time.
0 commit comments