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_r366232993
##########
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:
if we add check for this, do we also have to add check for
https://github.com/apache/spark/blob/1846b0261b84ce1bca079bc59fb4518bff910c18/sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala#L138
?
----------------------------------------------------------------
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]