Skip to content

Commit 37866b4

Browse files
authored
fix(arrow-schema): Persist dictionary ordered flag on FFI schema import (#10514)
# Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. --> - Closes #10513. # Rationale for this change See issue. # What changes are included in this PR? n/a # Are these changes tested? Unit test is added. # Are there any user-facing changes? n/a
1 parent fd8ead5 commit 37866b4

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

arrow-schema/src/ffi.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,9 @@ impl TryFrom<&FFI_ArrowSchema> for Field {
649649

650650
fn try_from(c_schema: &FFI_ArrowSchema) -> Result<Self, ArrowError> {
651651
let dtype = DataType::try_from(c_schema)?;
652-
let mut field = Field::new(c_schema.name().unwrap_or(""), dtype, c_schema.nullable());
653-
field.set_metadata(c_schema.metadata()?);
652+
let field = Field::new(c_schema.name().unwrap_or(""), dtype, c_schema.nullable())
653+
.with_dict_is_ordered(c_schema.dictionary_ordered())
654+
.with_metadata(c_schema.metadata()?);
654655
Ok(field)
655656
}
656657
}
@@ -988,6 +989,10 @@ mod tests {
988989

989990
let arrow_schema = FFI_ArrowSchema::try_from(schema).unwrap();
990991
assert!(arrow_schema.child(0).dictionary_ordered());
992+
993+
// Round-trip: the ordered flag must be preserved when converting back to a Field.
994+
let field = Field::try_from(arrow_schema.child(0)).unwrap();
995+
assert_eq!(field.dict_is_ordered(), Some(true));
991996
}
992997

993998
#[test]

0 commit comments

Comments
 (0)