-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Handle query returned with empty rows gracefully on bigquery enrichmement #36791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @AMOOOMA, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the BigQuery enrichment handler by providing a configurable mechanism to manage situations where an enrichment query returns no data. Previously, such scenarios might lead to errors, but now users can choose to either raise an exception or gracefully return the original, unenriched data, improving the robustness and flexibility of data pipelines. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
The Workflow run is cancelling this PR. It is an earlier duplicate of 1729654 run. |
|
The Workflow run is cancelling this PR. It is an earlier duplicate of 2083803 run. |
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
assign set of reviewers test failure seems to be unrelated to the changes |
|
Assigning reviewers: R: @claudevdm for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
/gemini review |
There was a problem hiding this comment.
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 adds a useful feature to the BigQueryEnrichmentHandler to gracefully handle cases where a query returns no results, by returning the original unenriched data. The implementation is controlled by a new throw_exception_on_empty_results parameter and is well-covered by new integration tests. My review includes a critical correction for a typo in this new parameter's name, which affects the public API, along with suggestions to improve performance and code readability.
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py
Outdated
Show resolved
Hide resolved
…y_it_test.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…y.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…y_it_test.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…y.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…y.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
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 graceful handling mechanism for empty query results in the BigQuery enrichment handler, controlled by a new throw_exception_on_empty_results parameter. The changes are well-implemented and include a comprehensive set of integration tests. My review includes a few suggestions to improve code consistency and test coverage: using f-strings for exceptions and deferred formatting for logging, fixing a typo in a test name, and adding a test case for partial batch results with exceptions enabled.
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
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 graceful handling mechanism for BigQuery enrichment queries that return no results. By adding the throw_exception_on_empty_results parameter, users can now choose between raising an exception (the default, preserving old behavior for non-batched queries) or returning the original data unenriched, which is a great improvement for flexibility. The implementation is solid, covering both batched and non-batched requests, and is well-supported by a comprehensive set of new integration tests. I've added one suggestion to refactor the logic for handling missing responses in batched mode to improve clarity and efficiency. Overall, this is a valuable enhancement to the BigQuery enrichment handler.
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
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 adds a throw_exception_on_empty_results flag to the BigQueryEnrichmentHandler to allow for graceful handling of empty query results. The changes are well-implemented and include comprehensive integration tests. My review includes suggestions to improve the efficiency of query execution for non-batched requests and to enhance logging by making it more secure and readable, avoiding potentially large and sensitive query strings in logs.
|
Acked some of gemini's review in the end because it seems like it's not really needed. |
claudevdm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you to run the bigquery_it_test to validate that that they pass? They arent triggered by the precommit actions.
|
Yep! I ran with the latest code and they are all green |
claudevdm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
|
R: @tvalentyn for final approval |
Handle query returned with empty rows gracefully on bigquery enrichmement handler
Returns the original unenriched data if no rows are returned from the enrichment table query
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.