From e44f1add594050c164ce2151a9eb17c035b0ff59 Mon Sep 17 00:00:00 2001 From: Helgi Kristvin Sigurbjarnarson Date: Tue, 26 Oct 2021 04:06:18 -0700 Subject: [PATCH] fix(ipc): Support serializing structs containing dictionaries (#848) * 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 --- arrow/src/ipc/convert.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/arrow/src/ipc/convert.rs b/arrow/src/ipc/convert.rs index 5244a387c90b..dcc9fcc84a0f 100644 --- a/arrow/src/ipc/convert.rs +++ b/arrow/src/ipc/convert.rs @@ -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_, @@ -791,6 +777,18 @@ mod tests { ))), false, ), + Field::new( + "struct>", + DataType::Struct(vec![Field::new( + "dictionary", + DataType::Dictionary( + Box::new(DataType::Int32), + Box::new(DataType::Utf8), + ), + false, + )]), + false, + ), Field::new( "struct]>]>", DataType::Struct(vec![