Skip to content

Commit 13f2435

Browse files
committed
undo dtypes._dtype_from_string and apply json only
1 parent 2dc2dd0 commit 13f2435

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

bigframes/core/indexes/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def __new__(
8686
pd_df = pandas.DataFrame(index=data)
8787
block = df.DataFrame(pd_df, session=session)._block
8888
else:
89-
if isinstance(dtype, str):
90-
dtype = bigframes.dtypes.bigframes_type(dtype)
89+
if isinstance(dtype, str) and dtype.lower() == "json":
90+
dtype = bigframes.dtypes.JSON_DTYPE
9191
pd_index = pandas.Index(data=data, dtype=dtype, name=name)
9292
pd_df = pandas.DataFrame(index=pd_index)
9393
block = df.DataFrame(pd_df, session=session)._block

bigframes/dataframe.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,11 @@ def __init__(
196196
block = block.multi_apply_unary_op(ops.AsTypeOp(to_type=bf_dtype))
197197

198198
else:
199+
if isinstance(dtype, str) and dtype.lower() == "json":
200+
dtype = bigframes.dtypes.JSON_DTYPE
201+
199202
import bigframes.pandas
200203

201-
if isinstance(dtype, str):
202-
dtype = bigframes.dtypes.bigframes_type(dtype)
203204
pd_dataframe = pandas.DataFrame(
204205
data=data,
205206
index=index, # type:ignore

bigframes/dtypes.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,19 +637,17 @@ def _dtype_from_string(dtype_string: str) -> typing.Optional[Dtype]:
637637
return BIGFRAMES_STRING_TO_BIGFRAMES[
638638
typing.cast(DtypeString, str(dtype_string))
639639
]
640-
if isinstance(dtype_string, str) and dtype_string.lower() == "json":
641-
return JSON_DTYPE
642640
raise TypeError(
643641
textwrap.dedent(
644642
f"""
645-
Unexpected data type string `{dtype_string}`. The following
643+
Unexpected data type string {dtype_string}. The following
646644
dtypes are supppted: 'boolean','Float64','Int64',
647-
'int64[pyarrow]','string','string[pyarrow]','json',
645+
'int64[pyarrow]','string','string[pyarrow]',
648646
'timestamp[us, tz=UTC][pyarrow]','timestamp[us][pyarrow]',
649647
'date32[day][pyarrow]','time64[us][pyarrow]'.
650-
The following pandas `ExtensionDtype` are supported:
651-
pd.BooleanDtype(), pd.Float64Dtype(),
652-
pd.Int64Dtype(), pd.StringDtype(storage="pyarrow"),
648+
The following pandas.ExtensionDtype are supported:
649+
pandas.BooleanDtype(), pandas.Float64Dtype(),
650+
pandas.Int64Dtype(), pandas.StringDtype(storage="pyarrow"),
653651
pd.ArrowDtype(pa.date32()), pd.ArrowDtype(pa.time64("us")),
654652
pd.ArrowDtype(pa.timestamp("us")),
655653
pd.ArrowDtype(pa.timestamp("us", tz="UTC")).

bigframes/operations/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def __init__(
121121
bf_dtype = bigframes.dtypes.bigframes_type(dtype)
122122
block = block.multi_apply_unary_op(ops.AsTypeOp(to_type=bf_dtype))
123123
else:
124-
if isinstance(dtype, str):
125-
dtype = bigframes.dtypes.bigframes_type(dtype)
124+
if isinstance(dtype, str) and dtype.lower() == "json":
125+
dtype = bigframes.dtypes.JSON_DTYPE
126126
pd_series = pd.Series(
127127
data=data,
128128
index=index, # type:ignore

0 commit comments

Comments
 (0)