Skip to content

Commit 153b82a

Browse files
authored
fix(sqlalchemy-bigquery): Support Creation of JSON columns (googleapis#16733)
Fixes googleapis#15761
1 parent 36ca46b commit 153b82a

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

packages/sqlalchemy-bigquery/sqlalchemy_bigquery/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,9 @@ def visit_BINARY(self, type_, **kw):
622622

623623
visit_VARBINARY = visit_BLOB = visit_BINARY
624624

625+
def visit_JSON(self, type_, **kw):
626+
return "JSON"
627+
625628
def visit_NUMERIC(self, type_, **kw):
626629
if (type_.precision is not None) and isinstance(
627630
kw.get("type_expression"), Column

packages/sqlalchemy-bigquery/tests/unit/test_table_options.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ def test_table_default_rounding_mode_dialect_option(faux_conn):
6262
)
6363

6464

65+
def test_table_with_json_columns(faux_conn):
66+
setup_table(
67+
faux_conn,
68+
"some_table",
69+
sqlalchemy.Column("some_stuff", sqlalchemy.JSON),
70+
)
71+
72+
assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
73+
"CREATE TABLE `some_table` ( `some_stuff` JSON )"
74+
)
75+
76+
6577
def test_table_clustering_fields_dialect_option_no_such_column(faux_conn):
6678
with pytest.raises(sqlalchemy.exc.NoSuchColumnError):
6779
setup_table(

0 commit comments

Comments
 (0)