Skip to content

Conversation

@friendlymatthew
Copy link
Contributor

@friendlymatthew friendlymatthew commented Nov 20, 2025

Rationale for this change

This PR introduces UnionFields::try_new and UnionFields::from_fields as replacements for the "unsafe" UnionFields::new constructor, which is now deprecated

Previously, UnionFields could be constructed with invalid invariants including negative type ids, duplicate type ids, or duplicate fields. Since UnionArrays index by type id, negative values cause panics at runtimes and duplicates break comparisons.

UnionFields::try_new validates that type ids are non-negative, unique, under 128, and that fields are unique, returning an error if any constraint is violated.

UnionFields::from_fields is a convenience constructor that auto-assigns sequential type ids starting from 0. (Will panic if it exceeds 128 elements)

Note about reviewing

I broke it up into smaller commits. The last commit updates all call sites across the different kernels

@github-actions github-actions bot added arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate parquet-variant parquet-variant* crates arrow-avro arrow-avro crate labels Nov 20, 2025
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 arrow-avro arrow-avro crate arrow-flight Changes to the arrow-flight crate parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant