File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1414
1515import pyarrow as pa
1616
17+ from bigframes import dtypes
18+
1719
1820def 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 ))
You can’t perform that action at this time.
0 commit comments