Repository navigation
Conversation
Creating a Spanner change stream with custom retention and transaction exclusion options previously had only SQL DDL snippets.
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces Python samples for Cloud Spanner change streams, including a script to create a change stream via DDL and corresponding unit and integration tests. A review comment points out a redundant nested os.environ.get call in the test configuration file (conftest.py) that should be simplified.
| LIVE_DATABASE_ID = os.environ.get( | ||
| "SPANNER_DATABASE_ID", os.environ.get("SPANNER_DATABASE_ID", "") | ||
| ) |
There was a problem hiding this comment.
Thanks! This comment refers to an earlier revision of this file; the code here has since been reworked in later commits, so this thread no longer applies to the current diff.
Avoids printing project identifiers in stdout or stderr and simplifies duplicate environment variable lookup in test configuration.
Prints only runtime resource and query results instead of hardcoded string literals.
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.
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/change_streams/src/spanner_change_streams/create_change_stream.py
Description
Configuring a Cloud Spanner change stream with custom retention and
allow_txn_exclusion = truefrom Python requires submittingCREATE CHANGE STREAMthroughDatabaseAdminClient.update_database_ddl.Establishes
spanner/change_streamsand addsspanner_create_change_stream.Checklist
Testing
Compliance & Style
spanner/, which the default repository owners cover.Post-Approval Actions