Skip to content

feat(spanner): Add PostgreSQL ALTER SEQUENCE SKIP RANGE sample - #14940

Open
iennae wants to merge 3 commits into
feat/spanner-postgresql-dml-last-statementfrom
feat/spanner-postgresql-alter-sequence
Open

iennae wants to merge 3 commits into
feat/spanner-postgresql-dml-last-statementfrom
feat/spanner-postgresql-alter-sequence

Conversation

@iennae

@iennae iennae commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Description

Adds spanner_postgresql_alter_sequence configuring SKIP RANGE on a PostgreSQL bit-reversed sequence and inserting rows.

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

Migrating existing integer IDs into a PostgreSQL-dialect table skips reserved ranges on a bit-reversed sequence via ALTER SEQUENCE ... SKIP RANGE. Add spanner_postgresql_alter_sequence.
@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 script and corresponding tests to alter a PostgreSQL bit-reversed sequence 'SKIP RANGE' and insert rows in a Spanner database with a PostgreSQL dialect. Specifically, it adds 'postgresql_alter_sequence.py' to perform the DDL update and transaction execution, and 'postgresql_alter_sequence_test.py' to verify the functionality through unit and live tests. There are no review comments, and we have no feedback to provide.

…ence

Problem: the sample waits on a long-running operation with a client-side
timeout. When that wait expires the client raises TimeoutError, which is
not an API call error, so the sample ended with an unhandled traceback.

Solution: catch TimeoutError and print a clear message to stderr noting
that only the wait timed out and the operation may still be running (the
timeout does not cancel it). Add a unit test covering the new handler.
…uence

Problem: multi-line SQL and DDL statements were written as adjacent string
fragments. That style is easy to get wrong (a missing trailing space joins
two SQL tokens) and is harder to read than the statement itself, and the
samples in this set mixed it with triple-quoted SQL.

Solution: write each multi-line statement as a single triple-quoted string,
matching the layout already used by the other samples. Only whitespace
between SQL tokens changes; the statements are otherwise identical.

Files updated:
  - spanner/postgresql/src/spanner_postgresql/postgresql_alter_sequence.py
@amcolin amcolin self-assigned this Nov 19, 2026
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