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/02/03 14:35:07 UTC

[GitHub] [spark] Zhen-hao commented on a change in pull request #35379: [SPARK-38091][SQL] fix bugs in AvroSerializer

Zhen-hao commented on a change in pull request #35379:
URL: https://github.com/apache/spark/pull/35379#discussion_r798625000



##########
File path: external/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala
##########
@@ -124,26 +136,51 @@ private[sql] class AvroSerializer(
       case (DoubleType, DOUBLE) =>
         (getter, ordinal) => getter.getDouble(ordinal)
       case (d: DecimalType, FIXED)
-        if avroType.getLogicalType == LogicalTypes.decimal(d.precision, d.scale) =>
+          if avroType.getLogicalType == LogicalTypes.decimal(d.precision, d.scale) =>
         (getter, ordinal) =>
-          val decimal = getter.getDecimal(ordinal, d.precision, d.scale)
-          decimalConversions.toFixed(decimal.toJavaBigDecimal, avroType,
-            LogicalTypes.decimal(d.precision, d.scale))
+          getter.get(ordinal, d) match {
+            case bigDecimal: java.math.BigDecimal =>
+              decimalConversions.toFixed(
+                bigDecimal,
+                avroType,
+                LogicalTypes.decimal(bigDecimal.precision, bigDecimal.scale))

Review comment:
       you are right. even though `bigDecimal.precision` should have the same value as `d.precision`, that's more of an implementation detail. I'll make the change 




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