@@ -720,17 +720,12 @@ def to_pandas_batches(
720720 series_map = {}
721721 for col in itertools .chain (self .value_columns , self .index_columns ):
722722 dtype = self .expr .get_column_type (col )
723- if bigframes .dtypes .contains_db_dtypes_json_dtype (dtype ):
724- # Due to a limitation in Apache Arrow (#45262), JSON columns are not
725- # natively supported by the to_pandas_batches() method, which is
726- # used by the anywidget backend.
727- # Workaround for https://github.com/googleapis/python-bigquery-dataframes/issues/1273
728- # PyArrow doesn't support creating an empty array with db_dtypes.JSONArrowType,
729- # especially when nested.
723+ try :
724+ series_map [col ] = pd .Series ([], dtype = dtype )
725+ except pa .ArrowNotImplementedError :
726+ # PyArrow doesn't support creating an empty array with
727+ # db_dtypes.JSONArrowType, especially when nested.
730728 # Create with string type and then cast.
731-
732- # MyPy doesn't automatically narrow the type of 'dtype' here,
733- # so we add an explicit check.
734729 if isinstance (dtype , pd .ArrowDtype ):
735730 safe_pa_type = bigframes .dtypes ._replace_json_arrow_with_string (
736731 dtype .pyarrow_dtype
@@ -742,8 +737,6 @@ def to_pandas_batches(
742737 # contains_db_dtypes_json_dtype is accurate,
743738 # but it's here for MyPy's sake.
744739 series_map [col ] = pd .Series ([], dtype = dtype )
745- else :
746- series_map [col ] = pd .Series ([], dtype = dtype )
747740 empty_val = pd .DataFrame (series_map )
748741 dfs = map (
749742 lambda a : a [0 ],
0 commit comments