Skip to content

Redshift ALTER TABLE ALTER COLUMN cannot run inside a transaction block #5572

Description

@jessica-ol

When a column type change is recognised by sqlmesh, it runs a command like this in the database

/* SQLMESH_PLAN: 12345asdf */ ALTER TABLE "my_catalog"."my_schema"."my_schema__my_table__12345678" ALTER COLUMN "my_column" TYPE VARCHAR(355)

However in Redshift, "alter table alter column" commands are not allowed within a transaction (see documentation: https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html), so the query errors with

ALTER TABLE ALTER COLUMN cannot run inside a transaction block

Note that sqlmesh only logs that the transaction is aborted, and not which tables or columns are causing the issue.

sqlmesh.utils.errors.PlanError: {'S': 'ERROR', 'C': '25P02', 'M': 'current transaction is aborted, commands ignored until end of transaction block', 'F': '/opt/brazil-pkg-cache/packages/RedshiftPADB/RedshiftPADB-1.0.48169.0/AL2_aarch64/generic-flavor/src/src/pg/src/backend/tcop/postgres.c', 'L': '4515', 'R': 'exec_parse_message'}

Expected behaviour: These commands should be executed outside of a transaction. Or until this is possible, the required manual changes should be logged in the sqlmesh plan before failing to allow users to make the changes in one go before retrying

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions