fix(ffi): preserve dictionary ordered flag when importing FFI schema - #10515
Closed
fuleinist wants to merge 1 commit into
Closed
fix(ffi): preserve dictionary ordered flag when importing FFI schema#10515fuleinist wants to merge 1 commit into
fuleinist wants to merge 1 commit into
Conversation
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
Contributor
|
thanks for the submission, but we have an existing PR for this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When converting an
FFI_ArrowSchema(C Data Interface) into aField, thedictionary ordered flag is silently dropped.
FFI_ArrowSchema::dictionary_ordered()reads the
ARROW_FLAG_DICTIONARY_ORDEREDbit (0b1) fromArrowSchema.flagscorrectly — but
impl TryFrom<&FFI_ArrowSchema> for Fieldnever applies it to theresulting
Field.As a result, a dictionary field exported with
dict_is_ordered = truealways comesback as
dict_is_ordered = falseafter an FFI round trip.Fix
One-line change: call
.with_dict_is_ordered(c_schema.dictionary_ordered())whenconstructing the
Fieldin theTryFrom<&FFI_ArrowSchema>impl.with_dict_is_orderedis a no-op on non-dictionary types, so this is safe for allschema types.
Test
Adds
test_dictionary_ordered_roundtripthat verifies both the ordered andunordered paths survive an export/import round trip through the C Data Interface.
Fixes #10513