Skip to content

Fix union cast incorrectness for duplicate field names#9666

Merged
alamb merged 1 commit intoapache:mainfrom
pydantic:friendlymatthew/use-type-id-union-extract
Apr 10, 2026
Merged

Fix union cast incorrectness for duplicate field names#9666
alamb merged 1 commit intoapache:mainfrom
pydantic:friendlymatthew/use-type-id-union-extract

Conversation

@friendlymatthew
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

This PR fixes union_extract_by_type to select children by type id instead of field name

union_extract resolves children by field name, greedily returning the first match. When union_extract_by_type resolved the correct child via type and then called union_extract with just the field name, that name-based lookup could pick the wrong child if another field shared the same name

This commit exposes a public method union_extract_by_id that selects the child by type id directly. This way, it avoids the ambiguity mentioned above

@github-actions github-actions bot added the arrow Changes to the arrow crate label Apr 6, 2026
@friendlymatthew friendlymatthew force-pushed the friendlymatthew/use-type-id-union-extract branch from ec614b0 to 6766220 Compare April 6, 2026 15:07
Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @friendlymatthew

@alamb alamb merged commit a42c475 into apache:main Apr 10, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Union cast is incorrect for duplicate field names

2 participants