Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-3676: Produce valid toString() for UUID JSON #1979

Merged
merged 1 commit into from
Nov 23, 2022
Merged

AVRO-3676: Produce valid toString() for UUID JSON #1979

merged 1 commit into from
Nov 23, 2022

Conversation

andeb
Copy link
Contributor

@andeb andeb commented Nov 21, 2022

What is the purpose of the change

In addition to #1204, this pull request wraps UUIDs in quotes to produce a valid JSON.

Verifying this change

Added test that validates UUID toString() behaviour

Documentation

  • Does this pull request introduce a new feature? no

@github-actions github-actions bot added the Java Pull Requests for Java binding label Nov 21, 2022
@RyanSkraba RyanSkraba self-requested a review November 23, 2022 18:28
Copy link
Contributor

@RyanSkraba RyanSkraba left a comment

Choose a reason for hiding this comment

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

This LGTM -- keeping in mind (as always), parsing a data representation from .toString() is probably never really what the user wants, especially if they expect Avro-flavoured JSON encoding.

In this case, the right thing to do would be to use .toString() for debugging and a human-readable representation, and JsonEncoder to generate strict Avro JSON.

@RyanSkraba RyanSkraba changed the title java: Produce valid string for UUID JSON serialization AVRO-3676: Produce valid toString() for UUID JSON Nov 23, 2022
@RyanSkraba RyanSkraba merged commit bd18dbd into apache:master Nov 23, 2022
@RyanSkraba
Copy link
Contributor

Cherry-picked to branch-1.11.

I also created a JIRA to track this change: AVRO-3676 -- The ASF JIRA unfortunately needed to disable public signups -- would you like us to create an account for you for contributor credit?

@andeb
Copy link
Contributor Author

andeb commented Nov 29, 2022

Thank you @RyanSkraba. It would be great if you could create an account for me on JIRA.

Noted regarding data representation using .toString(). I use it as a trick for tests only where I assert some big Avro JSONs to the expected JSON in some tests.

Originally I was using JsonEncoder to generate the Avro JSON, however it was a bit tricky to assert fields with logicalType decimal and timestamp as they get encoded as byte and long and it is not immediately clear the conversion when reading the test.

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
2 participants