Skip to content

feat(bigquery): add bigquery_create_search_index sample to create a s… - #14714

Merged
iennae merged 1 commit into
mainfrom
feat/bq-create-search-index
Nov 3, 2026
Merged

iennae merged 1 commit into
mainfrom
feat/bq-create-search-index

Conversation

@iennae

@iennae iennae commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

…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)

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

@iennae
iennae requested review from a team and chalmerlowe as code owners November 1, 2026 20:20
@snippet-bot

snippet-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@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 1, 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 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.

Comment thread bigquery/search/noxfile_config.py Resolved
@iennae
iennae force-pushed the feat/bq-create-search-index branch from 1687fd4 to 5abcfd2 Compare November 2, 2026 21:43

@XrossFox XrossFox 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

@iennae
iennae force-pushed the feat/bq-create-search-index branch from 5abcfd2 to f102df8 Compare November 2, 2026 22:35
…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`)
@iennae
iennae force-pushed the feat/bq-create-search-index branch from f102df8 to c317432 Compare November 2, 2026 23:33
@iennae
iennae merged commit 4233b24 into main Nov 3, 2026
14 of 22 checks passed
@iennae
iennae deleted the feat/bq-create-search-index branch November 3, 2026 02:22
iennae added a commit that referenced this pull request Nov 3, 2026
… 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.
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