1. [SPARK-24468][SQL] Handle negative scale when adjusting precision for (details)
Commit 1582945d0472bd16b07fd4e79ac872533a6885cd by wenchen
[SPARK-24468][SQL] Handle negative scale when adjusting precision for
decimal operations
## What changes were proposed in this pull request?
In SPARK-22036 we introduced the possibility to allow precision loss in
arithmetic operations (according to the SQL standard). The
implementation was drawn from Hive's one, where Decimals with a negative
scale are not allowed in the operations.
The PR handles the case when the scale is negative, removing the
assertion that it is not.
## How was this patch tested?
added UTs
Author: Marco Gaido <>
Closes #21499 from mgaido91/SPARK-24468.
(cherry picked from commit f07c5064a3967cdddf57c2469635ee50a26d864c)
Signed-off-by: Wenchen Fan <>
The file was modifiedsql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/decimalArithmeticOperations.sql (diff)
The file was modifiedsql/core/src/test/resources/sql-tests/results/typeCoercion/native/decimalArithmeticOperations.sql.out (diff)
The file was modifiedsql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/DecimalPrecisionSuite.scala (diff)
The file was modifiedsql/catalyst/src/main/scala/org/apache/spark/sql/types/DecimalType.scala (diff)