Skip to content

feat(bigquery): add bigquery_search_exclude_columns sample to search … - #14733

Merged
iennae merged 1 commit into
mainfrom
feat/bq-search-exclude-columns
Nov 4, 2026
Merged

iennae merged 1 commit into
mainfrom
feat/bq-search-exclude-columns

Conversation

@iennae

@iennae iennae commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

…a table while excluding specific columns

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/search) needs a standalone, tested Python code sample demonstrating how to search a table while excluding specific columns (region tag bigquery_search_exclude_columns).

Solution:

  • Add search_exclude_columns(project_id: str) -> None in bigquery/search/bigquery_search_exclude_columns.py (Search all columns of a BigQuery table except specified excluded columns using SELECT AS STRUCT * EXCEPT(...).)
  • Add unit tests (bigquery/search/bigquery_search_exclude_columns_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:21
@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 api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples. labels 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 BigQuery search sample demonstrating how to search a table while excluding specific columns using SELECT AS STRUCT ... EXCEPT, along with its corresponding unit tests and configuration files. The feedback suggests updating the ignored Python versions in noxfile_config.py to align with the repository's testing guidelines of only testing the oldest and newest supported releases. Additionally, the unit tests should be improved by mocking the NotFound exception on query_job.result() rather than client.query() to more accurately simulate the asynchronous behavior of the BigQuery client.

Comment thread bigquery/search/noxfile_config.py Resolved
@iennae
iennae force-pushed the feat/bq-search-exclude-columns branch 2 times, most recently from 014b46c to 68475db Compare November 3, 2026 02:44

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

So, i was taking a look at the comment by gemini, and i think it's correct: calling client.query() initially, doesn't return an exception right away, because it's an asynchronous method, that means the exception will be stored in the QueryObject.exception if it fails. According to the docs on QueryObject, calling QueryJob.result() blocks current execution and awaits for the operation to finish, then, if an exeption is encountered, the exception is raised, so a more accurate mock of exception handling would be to add the exception to the result of result().

…a table while excluding specific columns

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/search)
needs a standalone, tested Python code sample demonstrating how to
search a table while excluding specific columns (region tag `bigquery_search_exclude_columns`).

Solution:
- Add `search_exclude_columns(project_id: str) -> None` in `bigquery/search/bigquery_search_exclude_columns.py`
  (Search all columns of a BigQuery table except specified excluded columns using SELECT AS STRUCT * EXCEPT(...).)
- Add unit tests (`bigquery/search/bigquery_search_exclude_columns_test.py`) covering both the success
  path and API error handling (`GoogleAPICallError`)
@iennae
iennae force-pushed the feat/bq-search-exclude-columns branch from 68475db to 1352f46 Compare November 3, 2026 23:32
@iennae
iennae merged commit 07dae72 into main Nov 4, 2026
14 of 22 checks passed
@iennae
iennae deleted the feat/bq-search-exclude-columns branch November 4, 2026 00:52
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