Repository navigation
Conversation
Secondary index guides build indexes online without blocking reads or writes via DatabaseAdminClient.update_database_ddl. Add a standalone spanner_create_index sample creating AlbumsByAlbumTitle.
|
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 a new script and associated tests for creating a secondary index on a Google Cloud Spanner database. Specifically, create_index.py defines a create_index function that executes a DDL statement to index Albums(AlbumTitle) and handles various API exceptions and timeouts. It also includes a CLI entry point. The accompanying test file, create_index_test.py, provides comprehensive unit and live integration tests to verify successful execution, error handling, and CLI functionality. There are no review comments, and the implementation looks solid, so I have no additional feedback to provide.
Problem: reviewers of this sample set asked for stricter and clearer tests and for a single source of truth for dependencies. Mocks were created without a spec, so a renamed client argument would pass silently; the mocked wait timeout was raised from the API call instead of from the operation's result; live tests did not say which environment variables they need; and some tests carried leftover or repeated lines. Package dependencies were pinned in both pyproject.toml and requirements.txt. Solution: where applicable to the files below, patch client classes with autospec=True, raise the mocked TimeoutError from operation.result(), document the required environment variables above each live test and skip when one is missing, remove unused or duplicated test lines, and join string literals that the formatter had left split on one line. For package scaffolding, read dependencies from requirements.txt and update the README install command to match. Files updated: - spanner/database_admin/tests/create_index_test.py
Description
Adds
spanner_create_indexcreating a GoogleSQL secondary index online viaDatabaseAdminClient.update_database_ddl.Checklist
Testing
Compliance & Style
spanner/, which the default repository owners cover.Post-Approval Actions