You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "tmoschou (via GitHub)" <gi...@apache.org> on 2024/02/26 08:01:30 UTC
Re: [PR] AVRO-3947: [Java] Support subclasses in custom LogicalType Conversions [avro]
tmoschou commented on PR #2766:
URL: https://github.com/apache/avro/pull/2766#issuecomment-1963521487
Okay, I have also extended the fix to handling other code like `GenericDatumWriter` by fixing `GenericData.getConversionByClass(datumClass, logicalType)` which also failed when writing datums with type `Class<? extends T>` rather than `Class<T>`. We didn't notice it before as we are using our own custom writer. The only other usage I can see potentially being a problem is `GenericData.getConversionByClass(class)` whose usage as far as I can tell is only used for schema inference in Reflect/Protobuf - I that case I think it makes sense to keep the old behaviour, although some might have knowledge that values of a specific logical type is always of a particular subclass, although they can always use `@AvroSchema` for Reflect data. E.g.
```java
class MyRecord {
String foo;
@AvroSchema("{\"type\":\"string\",\"logical-type\":\"json\"")
ObjectNode metadata;
}
```
where conversion is defined for `JsonNode` (`JsonNode.class.isAssignableFrom(ObjectNode.class)`)
--
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: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org