File tree Expand file tree Collapse file tree 2 files changed +1
-18
lines changed
Expand file tree Collapse file tree 2 files changed +1
-18
lines changed Original file line number Diff line number Diff line change @@ -721,9 +721,7 @@ def to_pandas_batches(
721721 # db_dtypes.JSONArrowType, especially when nested.
722722 # Create with string type and then cast.
723723 if isinstance (dtype , pd .ArrowDtype ):
724- safe_pa_type = bigframes .dtypes ._replace_json_arrow_with_string (
725- dtype .pyarrow_dtype
726- )
724+ safe_pa_type = bigframes .dtypes .to_storage_type (dtype .pyarrow_dtype )
727725 # Create empty array with safe type, but preserve original dtype metadata
728726 empty_array = pa .array ([], type = safe_pa_type )
729727 series_map [col ] = pd .Series (
Original file line number Diff line number Diff line change @@ -972,21 +972,6 @@ def contains_db_dtypes_json_dtype(dtype):
972972 return contains_db_dtypes_json_arrow_type (dtype .pyarrow_dtype )
973973
974974
975- def _replace_json_arrow_with_string (pa_type : pa .DataType ) -> pa .DataType :
976- """Recursively replace JSONArrowType with string type."""
977- if isinstance (pa_type , db_dtypes .JSONArrowType ):
978- return pa .string ()
979- if isinstance (pa_type , pa .ListType ):
980- return pa .list_ (_replace_json_arrow_with_string (pa_type .value_type ))
981- if isinstance (pa_type , pa .StructType ):
982- new_fields = [
983- field .with_type (_replace_json_arrow_with_string (field .type ))
984- for field in pa_type
985- ]
986- return pa .struct (new_fields )
987- return pa_type
988-
989-
990975def warn_on_db_dtypes_json_dtype (dtypes ):
991976 """Warn that the JSON dtype is changing.
992977
You can’t perform that action at this time.
0 commit comments