Skip to content

Commit 72ec2da

Browse files
committed
remove anywidget from early return, allow execution proceeds to _repr_html_()
1 parent b62583a commit 72ec2da

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

bigframes/dataframe.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,21 @@ def _repr_html_(self) -> str:
863863
)
864864
return formatter.repr_query_job(self._compute_dry_run())
865865

866+
# The anywidget frontend doesn't support the db_dtypes JSON type, so
867+
# convert to strings for display.
868+
json_cols = [
869+
series_name
870+
for series_name, series in df.items()
871+
if bigframes.dtypes.contains_db_dtypes_json_dtype(series.dtype)
872+
]
873+
if json_cols:
874+
warnings.warn(
875+
"Converting JSON columns to strings for display. "
876+
"This is temporary and will be removed when the frontend supports JSON types."
877+
)
878+
for col in json_cols:
879+
df[col] = df[col]._apply_unary_op(ops.json_ops.ToJSONString())
880+
866881
# Always create a new widget instance for each display call
867882
# This ensures that each cell gets its own widget and prevents
868883
# unintended sharing between cells

bigframes/operations/output_schemas.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import pyarrow as pa
1616

17+
from bigframes import dtypes
18+
1719

1820
def parse_sql_type(sql: str) -> pa.DataType:
1921
"""
@@ -43,6 +45,9 @@ def parse_sql_type(sql: str) -> pa.DataType:
4345
if sql.upper() == "BOOL":
4446
return pa.bool_()
4547

48+
if sql.upper() == "JSON":
49+
return dtypes.JSON_ARROW_TYPE
50+
4651
if sql.upper().startswith("ARRAY<") and sql.endswith(">"):
4752
inner_type = sql[len("ARRAY<") : -1]
4853
return pa.list_(parse_sql_type(inner_type))

0 commit comments

Comments
 (0)