@@ -772,6 +772,13 @@ def convert_schema_field(
772772) -> typing .Tuple [str , Dtype ]:
773773 is_repeated = field .mode == "REPEATED"
774774 if field .field_type == "RECORD" :
775+ if field .description == OBJ_REF_DESCRIPTION_TAG :
776+ bf_dtype = OBJ_REF_DTYPE # type: ignore
777+ if is_repeated :
778+ pa_type = pa .list_ (bigframes_dtype_to_arrow_dtype (bf_dtype ))
779+ bf_dtype = pd .ArrowDtype (pa_type )
780+ return field .name , bf_dtype
781+
775782 mapped_fields = map (convert_schema_field , field .fields )
776783 fields = []
777784 for name , dtype in mapped_fields :
@@ -815,7 +822,11 @@ def convert_to_schema_field(
815822 )
816823 inner_field = convert_to_schema_field (name , inner_type , overrides )
817824 return google .cloud .bigquery .SchemaField (
818- name , inner_field .field_type , mode = "REPEATED" , fields = inner_field .fields
825+ name ,
826+ inner_field .field_type ,
827+ mode = "REPEATED" ,
828+ fields = inner_field .fields ,
829+ description = inner_field .description ,
819830 )
820831 if pa .types .is_struct (bigframes_dtype .pyarrow_dtype ):
821832 inner_fields : list [google .cloud .bigquery .SchemaField ] = []
@@ -827,6 +838,14 @@ def convert_to_schema_field(
827838 convert_to_schema_field (field .name , inner_bf_type , overrides )
828839 )
829840
841+ if bigframes_dtype == OBJ_REF_DTYPE :
842+ return google .cloud .bigquery .SchemaField (
843+ name ,
844+ "RECORD" ,
845+ fields = inner_fields ,
846+ description = OBJ_REF_DESCRIPTION_TAG ,
847+ )
848+
830849 return google .cloud .bigquery .SchemaField (
831850 name , "RECORD" , fields = inner_fields
832851 )
@@ -971,6 +990,7 @@ def lcd_type_or_throw(dtype1: Dtype, dtype2: Dtype) -> Dtype:
971990
972991
973992TIMEDELTA_DESCRIPTION_TAG = "#microseconds"
993+ OBJ_REF_DESCRIPTION_TAG = "bigframes_dtype: OBJ_REF_DTYPE"
974994
975995
976996def contains_db_dtypes_json_arrow_type (type_ ):
0 commit comments