wayneguow commented on code in PR #47651:
URL: https://github.com/apache/spark/pull/47651#discussion_r1717769551
##########
connector/avro/src/main/scala/org/apache/spark/sql/avro/AvroDeserializer.scala:
##########
@@ -386,14 +386,46 @@ private[sql] class AvroDeserializer(
case (LONG, _: DayTimeIntervalType) => (updater, ordinal, value) =>
updater.setLong(ordinal, value.asInstanceOf[Long])
- case (LONG, _: DecimalType) => (updater, ordinal, value) =>
- val d = avroType.getLogicalType.asInstanceOf[CustomDecimal]
- updater.setDecimal(ordinal, Decimal(value.asInstanceOf[Long],
d.precision, d.scale))
+ case (INT, dt: DecimalType) => avroType.getLogicalType match {
+ case null =>
Review Comment:
All of them are new feature supported.
1. For `int` field in Avro if we use `DecimalType` to read it:
- before, it throws a Exception;

- after, it can works;
And we also supported users to use `DecimalType` with `CustomDecimal` logic
Type to read `int` fields.
2. For long field in Avro if we use DecimalType to read it:
- before, it throws a Exception with cause NPE;

- after, it can works;
And if users use `DecimalType` with `CustomDecimal` logic Type to read
`long` fields, the exist feature still works.
--
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]