Skip to content

feat(bigquery): add bigquery_drop_vector_index sample to drop a vecto… - #14717

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

iennae merged 1 commit into
mainfrom
feat/bq-drop-vector-index

Conversation

@iennae

@iennae iennae commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

…r index from a table

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/vector-index) needs a standalone, tested Python code sample demonstrating how to drop a vector index from a table (region tag bigquery_drop_vector_index).

Solution:

  • Add drop_vector_index(project_id: str, dataset_id: str, table_id: str) -> None in bigquery/vector_search/bigquery_drop_vector_index.py (Remove a vector index from a BigQuery table using DROP VECTOR INDEX IF EXISTS.)
  • Add unit tests (bigquery/vector_search/bigquery_drop_vector_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:22
@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 new Python sample script and unit tests for dropping a BigQuery vector index. The feedback recommends updating the test configuration in noxfile_config.py to ignore intermediate Python versions, ensuring that only the oldest and newest supported releases are tested in compliance with repository guidelines.

@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, one depenedency is outdated.

Comment thread bigquery/vector_search/requirements.txt Outdated
@@ -0,0 +1 @@
google-cloud-bigquery==3.35.1

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.

Thise dependency is out of date, newest version of bigquery is 3.47.0

@iennae
iennae force-pushed the feat/bq-drop-vector-index branch 2 times, most recently from 7dc065c to ff22bd2 Compare November 2, 2026 22:35
…r index from a table

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/vector-index)
needs a standalone, tested Python code sample demonstrating how to
drop a vector index from a table (region tag `bigquery_drop_vector_index`).

Solution:
- Add `drop_vector_index(project_id: str, dataset_id: str, table_id: str) -> None` in `bigquery/vector_search/bigquery_drop_vector_index.py`
  (Remove a vector index from a BigQuery table using DROP VECTOR INDEX IF EXISTS.)
- Add unit tests (`bigquery/vector_search/bigquery_drop_vector_index_test.py`) covering both the success
  path and API error handling (`GoogleAPICallError`)
@iennae
iennae force-pushed the feat/bq-drop-vector-index branch from ff22bd2 to b736666 Compare November 2, 2026 23:33
@iennae
iennae merged commit dabfb54 into main Nov 3, 2026
14 of 22 checks passed
@iennae
iennae deleted the feat/bq-drop-vector-index branch November 3, 2026 02:24
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