[SPARK-46930][SQL] Add support for a custom prefix for Union type fields in Avro #44964
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.
What changes were proposed in this pull request?
This PR enhances stable ids functionality in Avro by allowing users to configure a custom prefix for Union type member fields when
enableStableIdentifiersForUnionTypeis enabled.Without the patch, the fields are generated with
member_prefix, e.g.member_int,member_string. This could become difficult to change for complex schemas.The solution is to add a new option
stableIdentifierPrefixForUnionTypewhich defaults tomember_and allows users to configure whatever prefix they require, e.g.member,tmp_, or even an empty string.Why are the changes needed?
Allows to customise the prefix of stable ids in Avro without the need to rename all of the columns which could be cumbersome for complex schemas.
Does this PR introduce any user-facing change?
Yes. The PR adds a new option in Avro:
stableIdentifierPrefixForUnionType.How was this patch tested?
Existing tests + a new unit test to verify different prefixes.
Was this patch authored or co-authored using generative AI tooling?
No.