Skip to content

fix(ffi): preserve dictionary ordered flag when importing FFI schema - #10515

Closed
fuleinist wants to merge 1 commit into
apache:mainfrom
fuleinist:fix/preserve-dict-ordered-ffi-import
Closed

fix(ffi): preserve dictionary ordered flag when importing FFI schema#10515
fuleinist wants to merge 1 commit into
apache:mainfrom
fuleinist:fix/preserve-dict-ordered-ffi-import

Conversation

@fuleinist

Copy link
Copy Markdown

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.

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

The FFI import path (TryFrom<&FFI_ArrowSchema> for Field) reads the
data type, name and nullability but silently drops the dictionary
ordered flag. As a result, a dictionary field exported with
dict_is_ordered = true always comes back as false after an FFI round
trip.

Call .with_dict_is_ordered(c_schema.dictionary_ordered()) when
constructing the field to propagate the ARROW_FLAG_DICTIONARY_ORDERED
bit (0b1) from the C Data Interface into the imported Field.

Adds a test that verifies both the ordered and unordered paths survive
an export/import round trip.

Fixes apache#10513
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-schema labels Aug 2, 2026
@Jefffrey

Jefffrey commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

thanks for the submission, but we have an existing PR for this

@Jefffrey Jefffrey closed this Aug 2, 2026
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-schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dictionary "ordered" flag is not preserved when importing an FFI (C Data Interface) schema

2 participants