Skip to content

feat: Support deserializing based on fully qualified name for Union Variants#96

Open
PookieBuns wants to merge 1 commit intolerouxrgd:masterfrom
PookieBuns:master
Open

feat: Support deserializing based on fully qualified name for Union Variants#96
PookieBuns wants to merge 1 commit intolerouxrgd:masterfrom
PookieBuns:master

Conversation

@PookieBuns
Copy link

@PookieBuns PookieBuns commented Mar 8, 2026

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-avro is primarily created to work with the apache-avro crate, 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!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant