ump45nose opened a new pull request, #11638:
URL: https://github.com/apache/arrow-rs/pull/11638

   # Which issue does this PR close?
   
   - Closes #11576.
   
   # Rationale for this change
   
   `UnionFields` derived `Deserialize`, so deserializing could build a value 
with duplicate or negative type ids, skipping the checks that #11533 added to 
the other constructors.
   
   # What changes are included in this PR?
   
   `Serialize` is still derived (transparent), but `Deserialize` is now 
implemented by hand: it reads the same sequence of `(type_id, field)` pairs and 
builds the value with `UnionFields::try_new`, returning a serde error if 
validation fails. The wire format doesn't change, so anything serialized before 
still deserializes as long as it was valid.
   
   I kept serde rather than removing it, since `DataType` (and therefore 
`Field` and `Schema`) derive serde and need `UnionFields` to support it.
   
   # Are these changes tested?
   
   Yes, two new tests in `fields.rs` (behind the `serde` feature, using 
`postcard` like the existing `Field` serde tests): a round trip of a valid 
`UnionFields`, and deserializing input with a duplicate type id and with a 
negative type id, both of which now fail. The second test fails without this 
change.
   
   # Are there any significant user-facing changes?
   
   Deserializing an invalid `UnionFields` (or a `DataType::Union` containing 
one) now returns an error instead of succeeding.
   
   AI disclosure: I used an AI coding assistant to write the change, the tests 
and this description, and I reviewed all of it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to