Skip to content

feat: support generated columns #137

@skuruppu

Description

@skuruppu

Is your feature request related to a problem? Please describe.
I was trying to setup the following table:

singers = Table(
    "Singers",
    metadata,
    Column("SingerId", String(36), primary_key=True, nullable=False),
    Column("FirstName", String(200)),
    Column("LastName", String(200), nullable=False),
    Column("FullName", String(400), nullable=False, Computed("COALESCE(FirstName || ' ', '') || LastName")
)

and I got this error from the Spanner backend:

google.api_core.exceptions.InvalidArgument: 400 Error parsing Spanner DDL statement: CREATE TABLE `Singers` (\n\t`SingerId` STRING(36) NOT NULL, \n\t`FirstName` STRING(200), \n\t`LastName` STRING(200) NOT NULL, \n\t`FullName` STRING(400) GENERATED ALWAYS AS (COALESCE(FirstName || \' \', \'\') || LastName) NOT NULL\n) PRIMARY KEY (SingerId) : Syntax error on line 5, column 25: Expecting \')\' but found \'GENERATED\'

This happens because SQLAlchemy translates Generated("<computation>") to GENERATED ALWAYS AS (<computation>) STORED. But Spanner syntax for generated colums is AS (<computation>) STORED.

Describe the solution you'd like
Support generated columns as Spanner expects it.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner-sqlalchemy API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions