File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed
datasource-avro/src/avro_to_arrow
proto-common/src/from_proto Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -117,11 +117,8 @@ fn schema_to_field_with_props(
117117 . iter ( )
118118 . map ( |s| schema_to_field_with_props ( s, None , has_nullable, None ) )
119119 . collect :: < Result < Vec < Field > > > ( ) ?;
120- let type_ids = 0_i8 ..fields. len ( ) as i8 ;
121- DataType :: Union (
122- UnionFields :: try_new ( type_ids, fields) . unwrap ( ) ,
123- UnionMode :: Dense ,
124- )
120+ // Assign type_ids based on the order in which they appear
121+ DataType :: Union ( UnionFields :: from_fields ( fields) , UnionMode :: Dense )
125122 }
126123 }
127124 AvroSchema :: Record ( RecordSchema { fields, .. } ) => {
Original file line number Diff line number Diff line change @@ -304,16 +304,15 @@ impl TryFrom<&protobuf::arrow_type::ArrowTypeEnum> for DataType {
304304 } ;
305305 let union_fields = parse_proto_fields_to_fields ( & union. union_types ) ?;
306306
307- // Default to index based type ids if not provided
308- let type_ids: Vec < _ > = match union. type_ids . is_empty ( ) {
309- true => ( 0 ..union_fields. len ( ) as i8 ) . collect ( ) ,
310- false => union. type_ids . iter ( ) . map ( |i| * i as i8 ) . collect ( ) ,
311- } ;
312-
313- let union_fields =
307+ // Default to index based type ids if not explicitly provided
308+ let union_fields = if union. type_ids . is_empty ( ) {
309+ UnionFields :: from_fields ( union_fields)
310+ } else {
311+ let type_ids = union. type_ids . iter ( ) . map ( |i| * i as i8 ) ;
314312 UnionFields :: try_new ( type_ids, union_fields) . map_err ( |e| {
315313 DataFusionError :: from ( e) . context ( "Deserializing Union DataType" )
316- } ) ?;
314+ } ) ?
315+ } ;
317316 DataType :: Union ( union_fields, union_mode)
318317 }
319318 arrow_type:: ArrowTypeEnum :: Dictionary ( dict) => {
You can’t perform that action at this time.
0 commit comments