Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

sqlalchemy-bigquery: BigQueryTypeCompiler missing visit_JSON #16123

Copy link
Copy link

Description

@geoHeil
Issue body actions

Description

sqlalchemy-bigquery does not support sa.JSON() column type. BigQuery has natively supported the JSON type since 2022, but the SQLAlchemy dialect's BigQueryTypeCompiler has no visit_JSON method.

Error

sqlalchemy.exc.UnsupportedCompilationError: Compiler <sqlalchemy_bigquery.base.BigQueryTypeCompiler>
can't render element of type JSON

This occurs when running Alembic migrations that include sa.Column("my_col", sa.JSON(), ...) against BigQuery.

Reproduction

from sqlalchemy import create_engine, MetaData, Table, Column, JSON, String

engine = create_engine("bigquery://my-project/my_dataset")
metadata = MetaData()
Table("test", metadata, Column("id", String()), Column("data", JSON()))
metadata.create_all(engine)  # UnsupportedCompilationError

Expected behavior

sa.JSON() should compile to BigQuery's native JSON type in DDL statements, since BigQuery supports it.

Context

Discovered while setting up Alembic migrations for Metaxy's BigQuery metadata store: anam-org/metaxy#1072

Environment

  • sqlalchemy-bigquery==1.16.0
  • sqlalchemy==2.0.x
  • alembic==1.15.x
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.