This is an automated email from the ASF dual-hosted git repository. srowen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 0c7770f4de56 [MINOR][SQL] Use `DecimalType.MINIMUM_ADJUSTED_SCALE` instead of magic number `6` in `Divide` class 0c7770f4de56 is described below commit 0c7770f4de560ad74e93b0902ab7a6be52c655be Author: longfei.jiang <1251489...@qq.com> AuthorDate: Wed Jan 31 09:40:07 2024 -0600 [MINOR][SQL] Use `DecimalType.MINIMUM_ADJUSTED_SCALE` instead of magic number `6` in `Divide` class ### What changes were proposed in this pull request? Replace magic value `6` with constants `DecimalType.MINIMUM_ADJUSTED_SCALE` ### Why are the changes needed? Magic values are less self-documenting than constant values. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing UT `ArithmeticExpressionSuite#"SPARK-45786: Decimal multiply, divide, remainder, quot"` can provide testing ### Was this patch authored or co-authored using generative AI tooling? No Closes #44941 from jlfsdtc/magic_value. Authored-by: longfei.jiang <1251489...@qq.com> Signed-off-by: Sean Owen <sro...@gmail.com> --- .../scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala index a0fb17cec812..9f1b42ad84d3 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala @@ -810,7 +810,7 @@ case class Divide( DecimalType.adjustPrecisionScale(prec, scale) } else { var intDig = min(DecimalType.MAX_SCALE, p1 - s1 + s2) - var decDig = min(DecimalType.MAX_SCALE, max(6, s1 + p2 + 1)) + var decDig = min(DecimalType.MAX_SCALE, max(DecimalType.MINIMUM_ADJUSTED_SCALE, s1 + p2 + 1)) val diff = (intDig + decDig) - DecimalType.MAX_SCALE if (diff > 0) { decDig -= diff / 2 + 1 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org