@@ -25,7 +25,7 @@ use crate::errors::ParquetError;
2525use crate :: errors:: Result ;
2626use crate :: schema:: types:: { SchemaDescriptor , Type , TypePtr } ;
2727use arrow_schema:: { DataType , Field , Fields , SchemaBuilder } ;
28- use crate :: arrow:: schema:: extension:: add_extension_type;
28+ use crate :: arrow:: schema:: extension:: { add_extension_type, binary_to_binary_view } ;
2929
3030fn get_repetition ( t : & Type ) -> Repetition {
3131 let info = t. get_basic_info ( ) ;
@@ -173,7 +173,7 @@ impl Visitor {
173173
174174 let parquet_fields = struct_type. get_fields ( ) ;
175175
176- // Extract the arrow fields
176+ // Extract any arrow fields from the hints
177177 let arrow_fields = match & context. data_type {
178178 Some ( DataType :: Struct ( fields) ) => {
179179 if fields. len ( ) != parquet_fields. len ( ) {
@@ -221,10 +221,10 @@ impl Visitor {
221221 data_type,
222222 } ;
223223
224- if let Some ( child) = self . dispatch ( parquet_field, child_ctx) ? {
224+ if let Some ( mut child) = self . dispatch ( parquet_field, child_ctx) ? {
225225 // The child type returned may be different from what is encoded in the arrow
226226 // schema in the event of a mismatch or a projection
227- child_fields. push ( convert_field ( parquet_field, & child, arrow_field) ) ;
227+ child_fields. push ( convert_field ( parquet_field, & mut child, arrow_field) ) ;
228228 children. push ( child) ;
229229 }
230230 }
@@ -353,13 +353,13 @@ impl Visitor {
353353
354354 // Need both columns to be projected
355355 match ( maybe_key, maybe_value) {
356- ( Some ( key) , Some ( value) ) => {
356+ ( Some ( mut key) , Some ( mut value) ) => {
357357 let key_field = Arc :: new (
358- convert_field ( map_key, & key, arrow_key)
358+ convert_field ( map_key, & mut key, arrow_key)
359359 // The key is always non-nullable (#5630)
360360 . with_nullable ( false ) ,
361361 ) ;
362- let value_field = Arc :: new ( convert_field ( map_value, & value, arrow_value) ) ;
362+ let value_field = Arc :: new ( convert_field ( map_value, & mut value, arrow_value) ) ;
363363 let field_metadata = match arrow_map {
364364 Some ( field) => field. metadata ( ) . clone ( ) ,
365365 _ => HashMap :: default ( ) ,
@@ -496,8 +496,8 @@ impl Visitor {
496496 } ;
497497
498498 match self . dispatch ( item_type, new_context) {
499- Ok ( Some ( item) ) => {
500- let item_field = Arc :: new ( convert_field ( item_type, & item, arrow_field) ) ;
499+ Ok ( Some ( mut item) ) => {
500+ let item_field = Arc :: new ( convert_field ( item_type, & mut item, arrow_field) ) ;
501501
502502 // Use arrow type as hint for index size
503503 let arrow_type = match context. data_type {
@@ -545,7 +545,7 @@ impl Visitor {
545545///
546546/// The resulting Arrow [`Field`] will have the type dictated by the Parquet `field`, a name
547547/// dictated by the `parquet_type`, and any metadata from `arrow_hint`
548- fn convert_field ( parquet_type : & Type , field : & ParquetField , arrow_hint : Option < & Field > ) -> Field {
548+ fn convert_field ( parquet_type : & Type , field : & mut ParquetField , arrow_hint : Option < & Field > ) -> Field {
549549 let name = parquet_type. name ( ) ;
550550 let data_type = field. arrow_type . clone ( ) ;
551551 let nullable = field. nullable ;
@@ -576,7 +576,9 @@ fn convert_field(parquet_type: &Type, field: &ParquetField, arrow_hint: Option<&
576576 ) ;
577577 ret. set_metadata ( meta) ;
578578 }
579- add_extension_type ( ret, & parquet_type)
579+ let ret = add_extension_type ( ret, & parquet_type) ;
580+ field. arrow_type = binary_to_binary_view ( & field. arrow_type ) ;
581+ ret
580582 }
581583 }
582584}
0 commit comments