Repository navigation
feat(bigquery): add bigquery_create_search_index sample to create a s… - #14714
Conversation
|
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 script to create a BigQuery search index across all columns of a table, along with corresponding unit tests and configuration files. The feedback highlights two main improvements: first, removing 'IF NOT EXISTS' from the SQL query in bigquery_create_search_index.py to prevent the AlreadyExists exception handling from becoming dead code; second, updating the ignored Python versions in noxfile_config.py to align with the policy of testing only the oldest and newest supported releases.
1687fd4 to
5abcfd2
Compare
5abcfd2 to
f102df8
Compare
…earch index on a table Problem: The BigQuery documentation (https://cloud.google.com/bigquery/docs/search-index) needs a standalone, tested Python code sample demonstrating how to create a search index on a table (region tag `bigquery_create_search_index`). Solution: - Add `create_search_index(project_id: str, dataset_id: str, table_id: str) -> None` in `bigquery/search/bigquery_create_search_index.py` (Create a BigQuery search index on ALL COLUMNS or selected columns of a table using CREATE SEARCH INDEX.) - Add unit tests (`bigquery/search/bigquery_create_search_index_test.py`) covering both the success path and API error handling (`GoogleAPICallError`)
f102df8 to
c317432
Compare
… up test mocks Problem: Following review feedback across the BigQuery sample PRs (#14714, #14715, #14717): - `bigquery_create_search_index.py` should use `CREATE SEARCH INDEX IF NOT EXISTS` and handle `exceptions.NotFound` when the parent table or dataset is missing. - `bigquery_drop_vector_index.py` `NotFound` error message should reflect that `DROP VECTOR INDEX IF EXISTS` raises `NotFound` when the parent table or dataset is missing. - Unit tests in `bigquery_create_search_index_test.py`, `bigquery_drop_vector_index_test.py`, and `bigquery_query_manifest_external_table_test.py` defined unused mock attributes (`mock_row` on DDL statements and `mock_job.statement_type` on SELECT queries). Solution: - Restore `CREATE SEARCH INDEX IF NOT EXISTS` and catch `exceptions.NotFound` in `bigquery/search/bigquery_create_search_index.py` and its unit test. - Update the `NotFound` error message in `bigquery/vector_search/bigquery_drop_vector_index.py`. - Remove unused `mock_row` and `mock_job.statement_type` setup in the three corresponding unit test files.
…earch index on a table
Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/search-index) needs a standalone, tested Python code sample demonstrating how to create a search index on a table (region tag
bigquery_create_search_index).Solution:
create_search_index(project_id: str, dataset_id: str, table_id: str) -> Noneinbigquery/search/bigquery_create_search_index.py(Create a BigQuery search index on ALL COLUMNS or selected columns of a table using CREATE SEARCH INDEX.)bigquery/search/bigquery_create_search_index_test.py) covering both the success path and API error handling (GoogleAPICallError)Checklist
Testing
Compliance & Style
Post-Approval Actions