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

   # Which issue does this PR close?
   
   - Closes #11603
   
   # Rationale for this change
   
   Exporting a sorted map as a `Field` drops the keys-sorted flag. With 
`DataType::Map(entries, true)`, `FFI_ArrowSchema::try_from(&DataType)` sets 
`ARROW_FLAG_MAP_KEYS_SORTED`, but `FFI_ArrowSchema::try_from(&Field)` replaces 
it with only the nullable and dictionary-ordered flags, so 
`Field::try_from(&c_schema)` returns `Map(.., false)`. Struct, list, union and 
`Schema` children are exported as fields, so a sorted map inside any of them is 
imported as unsorted as well. Exporting the bare `DataType` already round-trips.
   
   # What changes are included in this PR?
   
   `TryFrom<&Field> for FFI_ArrowSchema` now combines the field's flags with 
the flags already set on the schema built from its data type, instead of 
overwriting them. `FFI_ArrowSchema::with_flags` is unchanged and still sets the 
flags it is given. It is called only from `arrow-schema/src/ffi.rs`; the other 
caller there, `TryFrom<&DataType>`, builds the schema from scratch and loses 
nothing.
   
   # Are these changes tested?
   
   Yes, two unit tests in `arrow-schema/src/ffi.rs`, using the existing 
round-trip helpers. Both fail on `main` and pass with this change:
   
   - `test_map_keys_sorted_field`: a map field with sorted and unsorted keys, 
nullable and not, keeps the keys-sorted and nullable flags and its data type 
through a round trip.
   - `test_map_keys_sorted_nested`: sorted and unsorted maps round-trip as 
children of a struct, a `List`, a dense union and a `Schema`.
   
   # Are there any significant user-facing changes?
   
   No.
   


-- 
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