Skip to content

feat(spanner): Add PostgreSQL DROP SEQUENCE DDL sample - #14941

Merged
iennae merged 1 commit into
feat/spanner-postgresql-dml-last-statementfrom
feat/spanner-postgresql-drop-sequence
Nov 18, 2026
Merged

iennae merged 1 commit into
feat/spanner-postgresql-dml-last-statementfrom
feat/spanner-postgresql-drop-sequence

Conversation

@iennae

@iennae iennae commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Description

Adds spanner_postgresql_drop_sequence detaching a column DEFAULT and dropping a PostgreSQL bit-reversed sequence via DDL.

Note: Stacked on #14851 (feat/spanner-postgresql-dml-last-statement) so this PR shows only this sample's diff. It will merge into main after #14851.

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended. Unit and live integration tests pass on Python 3.13.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

Dropping a sequence referenced by a column DEFAULT requires detaching the column default before executing DROP SEQUENCE. Add a standalone spanner_postgresql_drop_sequence sample and test suite.
@iennae
iennae requested review from a team as code owners November 18, 2026 05:14
@snippet-bot

snippet-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples. labels Nov 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Python script and corresponding tests to detach a column default and drop a PostgreSQL sequence in a Spanner database using DDL statements. The implementation includes error handling for failed preconditions and API call errors, as well as a command-line interface. There are no review comments, and I have no feedback to provide.

@amcolin amcolin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks ok to me just one small non-blocking suggestion.

f"on database '{database_id}' in instance '{instance_id}': {err.message}",
file=sys.stderr,
)
except exceptions.GoogleAPICallError as err:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the timeout error be caught as well?

except TimeoutError as err:
        print(
            f"error: timed out waiting to drop PostgreSQL sequence "
            f"'{sequence_name}' on database '{database_id}' in instance "
            f"'{instance_id}': {err}",
            file=sys.stderr,
        )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch, thank you! Since this PR was already merged into its base branch, I added the except TimeoutError handler and a unit test as a follow-up commit there (43569d5, part of #14851). The message notes that only the wait timed out and the operation may still be running, because the timeout does not cancel the schema change.

@iennae
iennae merged commit 637268f into feat/spanner-postgresql-dml-last-statement Nov 18, 2026
3 checks passed
@iennae
iennae deleted the feat/spanner-postgresql-drop-sequence branch November 18, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants