borchero opened a new issue, #10513:
URL: https://github.com/apache/arrow-rs/issues/10513
### Describe the bug
When converting an `FFI_ArrowSchema` (C Data Interface) into a Rust Field,
the dictionary ordered flag is silently dropped. The C Data Interface encodes
this via the `ARROW_FLAG_DICTIONARY_ORDERED` bit (`0b1`) in
`ArrowSchema.flags`, and `FFI_ArrowSchema::dictionary_ordered()` reads it
correctly — but `impl TryFrom<&FFI_ArrowSchema>` for `Field` never applies it
to the resulting `Field`. As a result, a dictionary field that is exported with
`dict_is_ordered = true` always comes back as `dict_is_ordered = false` after a
round trip through the FFI schema.
### To Reproduce
```rust
use arrow_schema::{DataType, Field};
use arrow_schema::ffi::FFI_ArrowSchema;
let field = Field::new(
"dict",
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
false,
)
.with_dict_is_ordered(true);
// Export to the C Data Interface and import back.
let ffi = FFI_ArrowSchema::try_from(&field).unwrap();
assert!(ffi.dictionary_ordered()); // OK — flag is set on the FFI schema
let roundtripped = Field::try_from(&ffi).unwrap();
assert_eq!(roundtripped.dict_is_ordered(), Some(true)); // FAILS: returns
Some(false)
```
### Expected behavior
Importing an `FFI_ArrowSchema` whose `DICTIONARY_ORDERED` flag is set should
produce a `Field` with `dict_is_ordered() == Some(true)`, so that exporting and
re-importing a dictionary field is a lossless round trip.
### Additional context
_No response_
--
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]