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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]