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

   ## Summary
   
   When converting an `FFI_ArrowSchema` (C Data Interface) into a `Field`, the
   dictionary ordered flag is silently dropped. 
`FFI_ArrowSchema::dictionary_ordered()`
   reads the `ARROW_FLAG_DICTIONARY_ORDERED` bit (`0b1`) from 
`ArrowSchema.flags`
   correctly — but `impl TryFrom<&FFI_ArrowSchema> for Field` never applies it 
to the
   resulting `Field`.
   
   As a result, a dictionary field exported with `dict_is_ordered = true` 
always comes
   back as `dict_is_ordered = false` after an FFI round trip.
   
   ## Fix
   
   One-line change: call `.with_dict_is_ordered(c_schema.dictionary_ordered())` 
when
   constructing the `Field` in the `TryFrom<&FFI_ArrowSchema>` impl.
   
   ```rust
   // Before
   let mut field = Field::new(c_schema.name().unwrap_or(""), dtype, 
c_schema.nullable());
   
   // After
   let mut field = Field::new(c_schema.name().unwrap_or(""), dtype, 
c_schema.nullable())
       .with_dict_is_ordered(c_schema.dictionary_ordered());
   ```
   
   `with_dict_is_ordered` is a no-op on non-dictionary types, so this is safe 
for all
   schema types.
   
   ## Test
   
   Adds `test_dictionary_ordered_roundtrip` that verifies both the ordered and
   unordered paths survive an export/import round trip through the C Data 
Interface.
   
   Fixes #10513
   


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