Repository navigation
feat(bigquery): add bigquery_search_with_analyzer_options sample to s… - #14722
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new BigQuery code sample demonstrating how to search a table using custom JSON analyzer_options in the SEARCH function, along with its corresponding unit tests and configuration files. The feedback recommends updating the ignored_versions list in noxfile_config.py to ensure only the oldest and newest supported Python versions (3.10 and 3.13) are tested, in accordance with the project's testing guidelines.
XrossFox
left a comment
There was a problem hiding this comment.
I left a few questions and suggestions.
| u.street_address, | ||
| @search_query, | ||
| analyzer => 'LOG_ANALYZER', | ||
| analyzer_options => '{{"token_filters": [{{"stop_words": ["Apt"]}}]}}' |
There was a problem hiding this comment.
I believe declaring stop_words outside the sql string and passing it as a value would point the usage better:
search_query = "Nelson Apt"
stop_words = "Apt"
sql = f"""
.
.
analyzer_options => '{{"token_filters": [{{"stop_words": ["{stop_words}"]}}]}}'276ef7f to
e0b9cf8
Compare
e0b9cf8 to
d3c9099
Compare
…earch text with custom JSON analyzer options Problem: The BigQuery documentation (https://cloud.google.com/bigquery/docs/search) needs a standalone, tested Python code sample demonstrating how to search text with custom JSON analyzer options (region tag `bigquery_search_with_analyzer_options`). Solution: - Add `search_with_analyzer_options(project_id: str) -> None` in `bigquery/search/bigquery_search_with_analyzer_options.py` (Run a BigQuery SEARCH query configured with custom JSON analyzer_options such as token_filters and stop_words.) - Add unit tests (`bigquery/search/bigquery_search_with_analyzer_options_test.py`) covering both the success path and API error handling (`GoogleAPICallError`)
d3c9099 to
50a8bec
Compare
…earch text with custom JSON analyzer options
Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/search) needs a standalone, tested Python code sample demonstrating how to search text with custom JSON analyzer options (region tag
bigquery_search_with_analyzer_options).Solution:
search_with_analyzer_options(project_id: str) -> Noneinbigquery/search/bigquery_search_with_analyzer_options.py(Run a BigQuery SEARCH query configured with custom JSON analyzer_options such as token_filters and stop_words.)bigquery/search/bigquery_search_with_analyzer_options_test.py) covering both the success path and API error handling (GoogleAPICallError)Checklist
Testing
Compliance & Style
Post-Approval Actions