Ngone51 commented on a change in pull request #26881: [SPARK-30252][SQL]
Disallow negative scale of Decimal
URL: https://github.com/apache/spark/pull/26881#discussion_r366110109
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala
##########
@@ -134,10 +137,16 @@ final class Decimal extends Ordered[Decimal] with
Serializable {
// result. For example, the precision of 0.01 equals to 1 based on the
definition, but
// the scale is 2. The expected precision should be 3.
this._precision = decimal.scale + 1
+ this._scale = decimal.scale
+ } else if (decimal.scale < 0 &&
!SQLConf.get.allowNegativeScaleOfDecimalEnabled) {
+ this._precision = decimal.precision - decimal.scale
Review comment:
It's possible. But we have `DecimalType` aside to do the check and fail if
we goes over the max precision.
----------------------------------------------------------------
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]