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

Grouping by struct member broken in 1.11 #1117

Copy link
Copy link
Open
@bnaul

Description

@bnaul
Issue body actions

The following worked in 1.10 but raises an exception in 1.11:

from sqlalchemy import create_engine, Table, Integer, MetaData, Column, select, func
from sqlalchemy_bigquery import STRUCT

engine = create_engine(f"bigquery:///tmp", echo=True)
metadata = MetaData()
table = Table(
    "table",
    metadata,
    Column("id", Integer, primary_key=True),
    Column("nested", STRUCT(x=Integer))
)

query = (
    select(
        table.c.nested.x.label("x"),
    )
    .group_by(
        "x"
    )
)
print(query.compile(engine))

->

UnsupportedCompilationError: Compiler <sqlalchemy.sql.compiler.StrSQLCompiler object at 0x102f35f00> can't render element of type <function struct_getitem_op at 0x30532a9e0> (Background on this error at: https://sqlalche.me/e/14/l7de)

I traced the issue back to this line: https://github.com/googleapis/python-bigquery-sqlalchemy/pull/1053/files#diff-efe1987a73ae5b54aa817dc8c70541025df89d9d08601c8ab33fa84ad8c09de7R344

Removing this check or catching the exception resolves the issue. Perhaps a safer way to do this check would be to see if it's a function and then check its name? Not totally sure but I'm sure you will know @tswast 🙂

Metadata

Metadata

Labels

api: bigqueryIssues related to the googleapis/python-bigquery-sqlalchemy API.Issues related to the googleapis/python-bigquery-sqlalchemy API.

Type

No 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.