Skip to content

fix: implement ArrayData::validate_values for union types - #11534

Merged
Jefffrey merged 2 commits into
apache:mainfrom
Jefffrey:union-validate-values
Oct 14, 2026
Merged

Jefffrey merged 2 commits into
apache:mainfrom
Jefffrey:union-validate-values

Conversation

@Jefffrey

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • None

Rationale for this change

Ensure our validation APIs actually validate, to ensure downstream usages can rely on enforced invariants.

What changes are included in this PR?

Implement validation logic for union arrays in ArrayData::validate_values:

  • check all type ids are valid (non-negative, associated with a field in UnionFields)
  • dense offsets are within bounds for associated child array

Are these changes tested?

Added new unit tests

Are there any significant user-facing changes?

No

@Jefffrey Jefffrey added the bug Squash those bugs label Oct 13, 2026
@github-actions github-actions Bot added the arrow-core Core crates related to representing arrow data label Oct 13, 2026
@Jefffrey
Jefffrey marked this pull request as ready for review October 13, 2026 07:25

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Jefffrey -- looks good to me

Comment thread arrow-data/src/data.rs
}

#[test]
fn test_union_validate_type_ids() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we also add a check for negative offsets?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added in 5e7f62b 👍

@Jefffrey
Jefffrey added this pull request to the merge queue Oct 14, 2026
@Jefffrey

Copy link
Copy Markdown
Contributor Author

thanks @alamb

Merged via the queue into apache:main with commit 23ac45e Oct 14, 2026
34 checks passed
@Jefffrey
Jefffrey deleted the union-validate-values branch October 14, 2026 13:49
alamb pushed a commit that referenced this pull request Oct 19, 2026
Jefffrey added a commit that referenced this pull request Oct 22, 2026
…n types (#11762)

- Backport #11534
- For inclusion in #11665

Cherry-pick of
23ac45e

Co-authored-by: Andrew Lamb <[email protected]>
alamb added a commit that referenced this pull request Oct 22, 2026
…n types (#11814)

- Backport #11534
- For inclusion in #11666

Cherry-pick of
23ac45e

Co-authored-by: Andrew Lamb <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow-core Core crates related to representing arrow data bug Squash those bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants