Skip to content

feat(bigquery): add bigquery_get_vector_index_status sample to check … - #14744

Open
iennae wants to merge 1 commit into
mainfrom
feat/bq-get-vector-index-status
Open

iennae wants to merge 1 commit into
mainfrom
feat/bq-get-vector-index-status

Conversation

@iennae

@iennae iennae commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

…vector index status and coverage

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/vector-index) needs a standalone, tested Python code sample demonstrating how to check vector index status and coverage (region tag bigquery_get_vector_index_status).

Solution:

  • Add get_vector_index_status(project_id: str, dataset_id: str, table_id: str) -> None in bigquery/vector_search/bigquery_get_vector_index_status.py (Query INFORMATION_SCHEMA.VECTOR_INDEXES to inspect vector index status, coverage percentage, and last refresh time.)
  • Add unit tests (bigquery/vector_search/bigquery_get_vector_index_status_test.py) covering both the success path and API error handling (GoogleAPICallError)

Description

Fixes #

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 2, 2026 23:24
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Nov 2, 2026
@snippet-bot

snippet-bot Bot commented Nov 2, 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 the samples Issues that are directly related to samples. label Nov 2, 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 and corresponding unit tests to query and inspect BigQuery vector index build status using INFORMATION_SCHEMA.VECTOR_INDEXES. The feedback suggests three improvements: updating the test configuration in noxfile_config.py to only test the oldest and newest supported Python versions (3.10 and 3.13), printing the retrieved coverage_percentage in the script's output, and updating the unit tests to assert that this coverage percentage is correctly displayed.


TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
"ignored_versions": ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"],

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.

medium

According to the repository's general rules, test configurations should only test the oldest and newest supported Python releases, ignoring intermediate versions. Since Python 3.10 is the oldest supported version and Python 3.13 is the newest, we should test 3.10 and 3.13, and ignore 3.11 and 3.12.

Suggested change
"ignored_versions": ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"],
"ignored_versions": ["2.7", "3.7", "3.8", "3.9", "3.11", "3.12"],
References
  1. Only test the oldest and newest supported Python releases in test configurations (such as noxfile_config.py), ignoring intermediate versions.

Comment on lines +72 to +78
index_name = rows[0].index_name if rows else "NONE"
index_status = rows[0].index_status if rows else "NONE"
print(f"Resource ID: {table_ref}")
print(f"Index Count: {len(rows)}")
print(f"Index Name: {index_name}")
print(f"Index Status: {index_status}")
print(f"Job ID: {query_job.job_id}")

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.

medium

The SQL query retrieves coverage_percentage from INFORMATION_SCHEMA.VECTOR_INDEXES, and the PR description mentions inspecting the coverage percentage. However, this value is currently not printed or exposed in the output. Let's print the coverage percentage as well.

    index_name = rows[0].index_name if rows else "NONE"
    index_status = rows[0].index_status if rows else "NONE"
    coverage_percentage = rows[0].coverage_percentage if rows else 0
    print(f"Resource ID: {table_ref}")
    print(f"Index Count: {len(rows)}")
    print(f"Index Name: {index_name}")
    print(f"Index Status: {index_status}")
    print(f"Coverage Percentage: {coverage_percentage}")
    print(f"Job ID: {query_job.job_id}"

Comment on lines +44 to +51
captured = capsys.readouterr()
assert (
"Resource ID: example-project.example_dataset.example_embeddings"
in captured.out
)
assert "Index Count: 1" in captured.out
assert "Index Name: example_vector_index" in captured.out
assert "Index Status: ACTIVE" in captured.out

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.

medium

Update the test assertions to verify that the coverage percentage is correctly printed in the output.

Suggested change
captured = capsys.readouterr()
assert (
"Resource ID: example-project.example_dataset.example_embeddings"
in captured.out
)
assert "Index Count: 1" in captured.out
assert "Index Name: example_vector_index" in captured.out
assert "Index Status: ACTIVE" in captured.out
captured = capsys.readouterr()
assert (
"Resource ID: example-project.example_dataset.example_embeddings"
in captured.out
)
assert "Index Count: 1" in captured.out
assert "Index Name: example_vector_index" in captured.out
assert "Index Status: ACTIVE" in captured.out
assert "Coverage Percentage: 100" in captured.out

@iennae
iennae force-pushed the feat/bq-get-vector-index-status branch 2 times, most recently from e36185f to b86a97c Compare November 3, 2026 02:44
…vector index status and coverage

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/vector-index)
needs a standalone, tested Python code sample demonstrating how to
check vector index status and coverage (region tag `bigquery_get_vector_index_status`).

Solution:
- Add `get_vector_index_status(project_id: str, dataset_id: str, table_id: str) -> None` in `bigquery/vector_search/bigquery_get_vector_index_status.py`
  (Query INFORMATION_SCHEMA.VECTOR_INDEXES to inspect vector index status, coverage percentage, and last refresh time.)
- Add unit tests (`bigquery/vector_search/bigquery_get_vector_index_status_test.py`) covering both the success
  path and API error handling (`GoogleAPICallError`)
@iennae
iennae force-pushed the feat/bq-get-vector-index-status branch from b86a97c to a216ed1 Compare November 3, 2026 23:32

@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

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