-
-
Notifications
You must be signed in to change notification settings - Fork 136
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 Schema generation: allow mapping Java Enum properties to Avro String values #494
Comments
Would this be possible wrt Avro schema limitations? Would new type be defined as Union, allowing both String and Enum? And which direction is the change? (older schema exception String, new Enum? Or vice versa) At So I am not 100% sure I yet understand the ask here. |
I am suggesting an option where the generated avro schema for an enum field would simply be String. This would enable extending the enum in the future, with no change in schema. |
@jlous Ah ok. Depending on how implemented it might even be a general At this point I probably won't have time to work on this in near term but would be happy to help if anyone else wants to tackle it. |
@jlous BTW: If you change in Avro schema enum to string type, serialization and deserialization should work already. |
I try to avoid enum in Avro schema. Serializing enum into string is a good idea. @cowtowncoder I think creating a new BTW: Here is a draft PR, #496, where this feature is controlled by
|
Ah. Sorry, saw this comment before adding a note on PR. Yes, I think |
Let's continue discussion in PR #496. |
With json, I could always extend an enum (on both sender and receiver ends), consider it a backwards compatible change, and the receiver could parse both old and new documents equally well.
With avro, altering an enum makes the entire schema incompatible, and an updated schema can not be used to read old docs.
For all my use cases, serialising all enums as string would be a completely acceptable strategy for avoiding this problem, and much preferable to versioned formats,
but jacksons avro support does not currently seem to offer this.
So I'm hoping for a new feature switch for avro: WRITE_ENUMS_AS_STRINGS or similar.
In my case I only really care about serialising, since the receiver is on a completely different platform, but I guess parity on the deserialising side would be natural to include.
The text was updated successfully, but these errors were encountered: