You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/09/04 05:24:40 UTC

[GitHub] [spark] SelfImpr001 commented on a diff in pull request #37732: [SPARK-40253] [SQL] Fixed loss of precision for writing 0.00 specific…

SelfImpr001 commented on code in PR #37732:
URL: https://github.com/apache/spark/pull/37732#discussion_r962252317


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala:
##########
@@ -76,8 +76,19 @@ object Literal {
       val decimal = Decimal(d)
       Literal(decimal, DecimalType.fromDecimal(decimal))
     case d: JavaBigDecimal =>
-      val decimal = Decimal(d)
-      Literal(decimal, DecimalType.fromDecimal(decimal))
+      Literal(Decimal(d), DecimalType(Math.max(d.precision, d.scale), d.scale()))
+      if (d.abs().compareTo(new JavaBigDecimal("0")) == 0) {

Review Comment:
   Yes, it is found that it only exists in Spark 2.4 + Hive 1.x, but there are still many people using 2.4 +, it is recommended to provide a patch solution



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org