Skip to content

Commit

Permalink
fix(ipc): Support serializing structs containing dictionaries (#848) (#…
Browse files Browse the repository at this point in the history
…865)

* fix(ipc): Support serializing structs containing dictionaries

Dictionary fields nested in structs were not properly marked as
dictionary fields when serializing to fb.

* style: cargo fmt

Co-authored-by: Helgi Kristvin Sigurbjarnarson <helgikrs@gmail.com>
  • Loading branch information
alamb and helgikrs committed Oct 27, 2021
1 parent 620282a commit 8845e91
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions arrow/src/ipc/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,21 +610,7 @@ pub(crate) fn get_fb_field_type<'a>(
// struct's fields are children
let mut children = vec![];
for field in fields {
let inner_types =
get_fb_field_type(field.data_type(), field.is_nullable(), fbb);
let field_name = fbb.create_string(field.name());
children.push(ipc::Field::create(
fbb,
&ipc::FieldArgs {
name: Some(field_name),
nullable: field.is_nullable(),
type_type: inner_types.type_type,
type_: Some(inner_types.type_),
dictionary: None,
children: inner_types.children,
custom_metadata: None,
},
));
children.push(build_field(fbb, field));
}
FBFieldType {
type_type: ipc::Type::Struct_,
Expand Down Expand Up @@ -791,6 +777,18 @@ mod tests {
))),
false,
),
Field::new(
"struct<dictionary<int32, utf8>>",
DataType::Struct(vec![Field::new(
"dictionary<int32, utf8>",
DataType::Dictionary(
Box::new(DataType::Int32),
Box::new(DataType::Utf8),
),
false,
)]),
false,
),
Field::new(
"struct<int64, list[struct<date32, list[struct<>]>]>",
DataType::Struct(vec![
Expand Down

0 comments on commit 8845e91

Please sign in to comment.