Skip to content

fix(bigquery): restore IF NOT EXISTS in create_search_index and clean up test mocks - #14754

Open
iennae wants to merge 1 commit into
mainfrom
fix/bq-merged-samples-cleanup
Open

iennae wants to merge 1 commit into
mainfrom
fix/bq-merged-samples-cleanup

Conversation

@iennae

@iennae iennae commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up cleanup for recently merged BigQuery sample PRs (#14714, #14715, #14717):

@iennae
iennae requested review from a team and chalmerlowe as code owners November 3, 2026 03:32
@product-auto-label product-auto-label Bot added api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples. labels Nov 3, 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 updates BigQuery search and vector index scripts and their corresponding tests. Specifically, it modifies the search index creation to use 'CREATE SEARCH INDEX IF NOT EXISTS' and updates the exception handling to catch 'exceptions.NotFound' instead of 'exceptions.AlreadyExists'. Additionally, it refactors error messages for missing tables or datasets in the vector index drop script and updates unit tests to use empty list results for mock query jobs. There are no review comments, so I have no feedback to provide.

… 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.
@iennae
iennae force-pushed the fix/bq-merged-samples-cleanup branch from 2ac3d30 to 260d2cb Compare November 3, 2026 23:32

@amcolin amcolin 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.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants