3131import pyarrow as pa
3232import shapely .geometry # type: ignore
3333
34- import bigframes .core .backports
3534import bigframes .exceptions
3635
3736# Type hints for Pandas dtypes supported by BigQuery DataFrame
@@ -397,6 +396,9 @@ def get_struct_fields(type_: ExpressionType) -> dict[str, Dtype]:
397396 assert isinstance (type_ .pyarrow_dtype , pa .StructType )
398397 struct_type = type_ .pyarrow_dtype
399398 result : dict [str , Dtype ] = {}
399+
400+ # Local import to break circular dependency with core.backports
401+ import bigframes .core .backports
400402 for field in bigframes .core .backports .pyarrow_struct_type_fields (struct_type ):
401403 result [field .name ] = arrow_dtype_to_bigframes_dtype (field .type )
402404 return result
@@ -582,6 +584,9 @@ def to_storage_type(
582584 return pa .list_ (to_storage_type (arrow_type .value_type ))
583585 if pa .types .is_struct (arrow_type ):
584586 assert isinstance (arrow_type , pa .StructType )
587+
588+ # Local import to break circular dependency with core.backports
589+ import bigframes .core .backports
585590 return pa .struct (
586591 field .with_type (to_storage_type (field .type ))
587592 for field in bigframes .core .backports .pyarrow_struct_type_fields (arrow_type )
@@ -595,6 +600,9 @@ def arrow_type_to_literal(
595600 """Create a representative literal value for an arrow type."""
596601 if pa .types .is_list (arrow_type ):
597602 return [arrow_type_to_literal (arrow_type .value_type )]
603+
604+ # Local import to break circular dependency with core.backports
605+ import bigframes .core .backports
598606 if pa .types .is_struct (arrow_type ):
599607 return {
600608 field .name : arrow_type_to_literal (field .type )
@@ -1001,6 +1009,8 @@ def contains_db_dtypes_json_arrow_type(type_):
10011009 return contains_db_dtypes_json_arrow_type (type_ .value_type )
10021010
10031011 if isinstance (type_ , pa .StructType ):
1012+ # Local import to break circular dependency with core.backports
1013+ import bigframes .core .backports
10041014 return any (
10051015 contains_db_dtypes_json_arrow_type (field .type )
10061016 for field in bigframes .core .backports .pyarrow_struct_type_fields (type_ )
0 commit comments