@@ -310,7 +310,11 @@ impl TryFrom<&protobuf::arrow_type::ArrowTypeEnum> for DataType {
310310 false => union. type_ids . iter ( ) . map ( |i| * i as i8 ) . collect ( ) ,
311311 } ;
312312
313- DataType :: Union ( UnionFields :: new ( type_ids, union_fields) , union_mode)
313+ let union_fields =
314+ UnionFields :: try_new ( type_ids, union_fields) . map_err ( |e| {
315+ DataFusionError :: from ( e) . context ( "Deserializing Union DataType" )
316+ } ) ?;
317+ DataType :: Union ( union_fields, union_mode)
314318 }
315319 arrow_type:: ArrowTypeEnum :: Dictionary ( dict) => {
316320 let key_datatype = dict. as_ref ( ) . key . as_deref ( ) . required ( "key" ) ?;
@@ -602,7 +606,9 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {
602606 . collect :: < Option < Vec < _ > > > ( ) ;
603607 let fields = fields. ok_or_else ( || Error :: required ( "UnionField" ) ) ?;
604608 let fields = parse_proto_fields_to_fields ( & fields) ?;
605- let fields = UnionFields :: new ( ids, fields) ;
609+ let union_fields = UnionFields :: try_new ( ids, fields) . map_err ( |e| {
610+ DataFusionError :: from ( e) . context ( "Deserializing Union ScalarValue" )
611+ } ) ?;
606612 let v_id = val. value_id as i8 ;
607613 let val = match & val. value {
608614 None => None ,
@@ -614,7 +620,7 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {
614620 Some ( ( v_id, Box :: new ( val) ) )
615621 }
616622 } ;
617- Self :: Union ( val, fields , mode)
623+ Self :: Union ( val, union_fields , mode)
618624 }
619625 Value :: FixedSizeBinaryValue ( v) => {
620626 Self :: FixedSizeBinary ( v. length , Some ( v. clone ( ) . values ) )
0 commit comments