Repository navigation
Conversation
Python developers implementing semantic similarity search on Cloud Spanner lacked a client library example showing parameterized FLOAT32 vector bindings with COSINE_DISTANCE.
Full-text search in Cloud Spanner depends on tokenized TOKENLIST columns indexed by CREATE SEARCH INDEX, which 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.
|
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new utility script to create a full-text search index in Google Cloud Spanner, along with comprehensive unit and integration tests to verify the functionality and error handling. As there were no review comments provided for this pull request, I have no feedback to offer.
Prints short resource identifiers instead of full project-prefixed resource paths and omits project_id from diagnostic messages.
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/search_and_ai/src/spanner_search_and_ai/create_search_index.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Full-text search in Cloud Spanner requires indexing generated
TOKENLISTcolumns withCREATE SEARCH INDEX, and unlikeCREATE TABLEorCREATE VECTOR INDEX,CREATE SEARCH INDEXdoes not acceptIF NOT EXISTSand raisesFailedPreconditionif the index already exists.Adds
spanner_create_search_indexdemonstrating asynchronous search index creation and duplicate-DDL error handling from Python.Checklist
Testing
Compliance & Style
spanner/, which the default repository owners cover.Post-Approval Actions