Skip to content

Conversation

@steven-aerts
Copy link
Contributor

Support unqualified type references for unions when decoding them from json.
AVRO-2287 makes it unclear if type reference for a JSON encoded union needs to be qualified or not.
Today all encoders use the fully qualified types except the C JSON encoder which uses the unqualified type.

In this patch we make the java JSON Decoder more lenient and let it fallback to unqualified types names when no qualified type name matches. Which matches the behavior currently implemented in the Javascript Json decoder.

This patch is an alternative for #3373 where it is proposed to update the C library instead.

Verifying this change

This change added tests and can be verified as follows: run newly added test: org.apache.avro.io.TestJsonDecoder#testUnionTypeQualification

Documentation

  • Does this pull request introduce a new feature? no

Support unqualified type references for unions when decoding them from
json.
AVRO-2287 makes it unclear if type reference for a JSON encoded union
needs to be qualified or not.
Today all encoders use the fully qualified types except the C JSON
encoder which uses the unqualified type.

In this patch we make the java JSON Decoder more lenient and let it
fallback to unqualified types names when no qualified type name
matches.  Which matches the behavior currently implemented in the
Javascript Json decoder.

This patch is an alternative for apache#3373 where it is proposed
to update the C library instead.
@github-actions github-actions bot added the Java Pull Requests for Java binding label May 7, 2025
Copy link
Contributor

@opwvhk opwvhk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the comments for #3373 (the other PR for AVRO-4135), there is a difference in how C and the other language implementations handle this case.

The C implementation has ambiguities when there are two records with the same unqualified name but different namespace.

As a result, I prefer #3373 to fix AVRO-4135.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants