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-4026: [c++] Allow non-string custom attributes in schemas #3069

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jmd-z
Copy link

@jmd-z jmd-z commented Aug 6, 2024

Custom attributes are encoded as JSON to avoid ambiguity with simple string values.

What is the purpose of the change

Fixes exception from C++ library when compiling schemas with non-string custom attributes.

Verifying this change

This change added tests and can be verified as follows:

  • Added test that compiles a schema with a non-string custom attribute

Documentation

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

…m attributes are JSON string to avoid ambiguity
@github-actions github-actions bot added the C++ Pull Requests for C++ binding label Aug 6, 2024
Copy link
Contributor

@pascalginter pascalginter left a comment

Choose a reason for hiding this comment

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

LGTM
I would be happy to see this PR revived and eventually merged

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: format the json over more lines for better readability

@martin-g
Copy link
Member

@Gerrit0 @mkmkme Do you want to review too ?

Copy link
Contributor

@mkmkme mkmkme left a comment

Choose a reason for hiding this comment

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

LGTM!

"\"mapField\": \"{\\\"key1\\\":\\\"value1\\\", \\\"key2\\\":\\\"value2\\\"}\", "
"\"nullField\": \"null\", "
"\"numberField\": \"1.23\", "
"\"arrayField\": [1], "
Copy link
Member

Choose a reason for hiding this comment

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

Looking at these changes I think this change may break someone's application.
Do we want to support a backward compatible encoding via some property/setting/... ?

@jmd-z
Copy link
Author

jmd-z commented Sep 26, 2024 via email

@martin-g
Copy link
Member

Perhaps renaming the function CustomAttributes::getAttributes to CustomAttributes::getAttributesJSON would do the same here.

Perhaps this would be the best!
In my experience (Java and Rust) the best is to keep the old behavior as deprecated and introduce a new one as the recommended. In a later version, e.g. 1.13.0, the deprecated method could be removed.

@pascalginter
Copy link
Contributor

It seems that everyone involved in this discussion agrees with @jmd-z's proposal, and the PR could be merged once the change is implemented. @jmd--z, do you have time to make the small adjustment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Pull Requests for C++ binding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants