feat(compiler): add union support to fory compiler and runtime#3195
Merged
chaokunyang merged 21 commits intoapache:mainfrom Jan 23, 2026
Merged
feat(compiler): add union support to fory compiler and runtime#3195chaokunyang merged 21 commits intoapache:mainfrom
chaokunyang merged 21 commits intoapache:mainfrom
Conversation
pandalee99
approved these changes
Jan 23, 2026
ff228ec to
6e79841
Compare
4c97df4 to
66fd0fa
Compare
66fd0fa to
be6c032
Compare
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.
Why?
Fory needs Union type support in its IDL compiler to enable cross-language serialization of sum types (tagged unions). This allows users to define Union types in FDL/Protobuf/FlatBuffers schemas and have the compiler generate code for all supported languages (Java, C++, Python, Go, Rust).
What does this PR do?
This PR adds comprehensive Union type support across the entire Fory stack:
Compiler & IDL:
Runtime Support:
Protocol & Xlang:
Testing:
Related issues
Closes #3182 #3191 #3170
#1017
#3099
Does this PR introduce any user-facing change?
Yes. Users can now define Union types in Fory IDL files and use Protobuf oneof or FlatBuffers union syntax which will be compiled to Fory Union types.
Benchmark
No performance regression expected. Union serialization uses the same optimized paths as existing reference serialization with additional index metadata.