avro icon indicating copy to clipboard operation
avro copied to clipboard

AVRO-3947: [Java] Support subclasses in custom LogicalType Conversions

Open tmoschou opened this issue 11 months ago • 1 comments

What is the purpose of the change

Currently GenericData.resolveUnion(schema, datum) will throw an AvroRuntimeException if datum is a subclass (or any instance) of the target type of an applicable logical type Conversion. For instance

  • "ip-address" logical type string converter to/from java.net.InetAddress (with Inet4Address, Inet6Address as subclasses)
  • "json" logical type string conversion to/from Jackson's JsonNode (with ObjectNode, ArrayNode, etc as subclasses)

This PR fixes AVRO-3947.

Verifying this change

A unit test was added to validate that GenericData.resolveUnion(schema, datum) behaves as intended.

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

tmoschou avatar Feb 26 '24 04:02 tmoschou