Skip to content

Conversation

@AMOOOMA
Copy link
Contributor

@AMOOOMA AMOOOMA commented Nov 11, 2025

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:

  • Mention the appropriate issue in your description (for example: 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, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

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

  • Configurable Empty Result Handling: Introduced a new throw_execption_on_empty_results parameter in BigQueryEnrichmentHandler to control behavior when queries yield no results.
  • Graceful Fallback: Implemented graceful handling for BigQuery enrichment queries that return empty rows, allowing the original unenriched data to be passed through instead of raising an error when throw_execption_on_empty_results is set to False.
  • Improved Logging: Added logging for cases where no matching rows are found during enrichment when graceful handling is enabled, providing better visibility into data flow.
  • Comprehensive Testing: Expanded integration tests to cover various scenarios of empty BigQuery results, including both exception-throwing and graceful fallback mechanisms for single and batched requests, and with and without custom query functions.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

The Workflow run is cancelling this PR. It is an earlier duplicate of 1729654 run.

@github-actions
Copy link
Contributor

The Workflow run is cancelling this PR. It is an earlier duplicate of 2083803 run.

@github-actions
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@AMOOOMA
Copy link
Contributor Author

AMOOOMA commented Nov 11, 2025

assign set of reviewers

test failure seems to be unrelated to the changes

@github-actions
Copy link
Contributor

Assigning reviewers:

R: @claudevdm for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@claudevdm
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

AMOOOMA and others added 6 commits November 12, 2025 14:03
…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>
@AMOOOMA
Copy link
Contributor Author

AMOOOMA commented Nov 12, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@AMOOOMA
Copy link
Contributor Author

AMOOOMA commented Nov 12, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@AMOOOMA
Copy link
Contributor Author

AMOOOMA commented Nov 12, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@AMOOOMA
Copy link
Contributor Author

AMOOOMA commented Nov 12, 2025

Acked some of gemini's review in the end because it seems like it's not really needed.

Copy link
Collaborator

@claudevdm claudevdm left a 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.

@AMOOOMA
Copy link
Contributor Author

AMOOOMA commented Nov 13, 2025

Yep! I ran with the latest code and they are all green

Copy link
Collaborator

@claudevdm claudevdm left a 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!

@github-actions
Copy link
Contributor

R: @tvalentyn for final approval

@tvalentyn tvalentyn merged commit 63a8be9 into apache:master Nov 13, 2025
99 of 101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants