feat: Support deserializing based on fully qualified name for Union Variants#96
Open
PookieBuns wants to merge 1 commit intolerouxrgd:masterfrom
Open
feat: Support deserializing based on fully qualified name for Union Variants#96PookieBuns wants to merge 1 commit intolerouxrgd:masterfrom
PookieBuns wants to merge 1 commit intolerouxrgd:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is another avro deserialization crate serde_avro_fast that supports schema aware deserialization (apache-avro is working on supporting it apache/avro-rs#237), and it utilizes the fully qualified name to deserialize the identifier for union variants (I'm assuming the reasoning is because of duplicate names from different namespaces being a valid schema). This change adds support for deserializing Union variants using their fully qualified name, while being backwards compatible by using
serde(alias)Although
rsgen-avrois primarily created to work with theapache-avrocrate, when schema aware deserialization lands, this is probably a feature that may need to be implemented anyways, so IMO its a good future proofing change.Note that this doesn't actually supports same names from different namespaces, it just supports identifying variants using the fully qualified name during deserialization.
Also made a change to throw an error if unions have the same name, since in the past, it would actually generate successfully code that doesn't compile (two identical variants/symbols in a rust enum).
Although it may not completely address the use case of #79, it could potentially be helpful (And it doesn't create extremely long type names :) ). Please let me know if you have any questions! Thanks!