Skip to content

Conversation

@shahar1
Copy link
Contributor

@shahar1 shahar1 commented Jan 25, 2026

related: #37431 (replaced #31126 which has been stale for too long)

Add an option to set a quota project in beam.io.ReadFromBigQuery in Python SDK.

Disclaimer: used Claude LLM to code it


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 @shahar1, 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 Apache Beam Python SDK by adding support for specifying a quota_project_id when reading data from BigQuery. This feature provides users with finer-grained control over billing for BigQuery API calls, enabling them to direct costs to a designated GCP project, which can be different from the project where the data resides or the service account is configured. The implementation involves updating BigQuery I/O components and credential handling to correctly apply this new configuration.

Highlights

  • Quota Project Support: Introduced quota_project_id parameter in beam.io.ReadFromBigQuery for Python SDK.
  • Flexible Billing: Allows users to specify a separate GCP project for billing BigQuery API requests, distinct from the data or service account project.
  • Credential Integration: Added a with_quota_project utility function to apache_beam.internal.gcp.auth to apply the quota project to Google Cloud credentials.
  • Pipeline Option Integration: The quota_project_id can be configured directly in ReadFromBigQuery or via GoogleCloudOptions in the pipeline.
  • Comprehensive Testing: New unit tests ensure correct handling, precedence, and propagation of the quota_project_id across different BigQuery read methods and client wrappers.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@shahar1 shahar1 force-pushed the gcp-set-quota-project-python branch 3 times, most recently from 25ecf8e to dfc2122 Compare January 26, 2026 19:53
@shahar1 shahar1 force-pushed the gcp-set-quota-project-python branch 4 times, most recently from e302df1 to 642daed Compare January 27, 2026 16:17
@shahar1 shahar1 marked this pull request as ready for review January 27, 2026 16:30
@shahar1
Copy link
Contributor Author

shahar1 commented Jan 27, 2026

/gemini review

@shahar1 shahar1 marked this pull request as draft January 27, 2026 16:31
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 support for setting a quota project ID in beam.io.ReadFromBigQuery within the Python SDK. This feature allows users to specify a billing project for BigQuery API requests, separate from the project owning the data or service account. The changes include adding a quota_project_id parameter to relevant BigQuery source classes, implementing logic to retrieve this ID from either explicit parameters or pipeline options, and integrating it into the BigQuery client creation process. Comprehensive unit tests have been added to validate the functionality across various scenarios, ensuring proper handling of credentials and quota project application. The new with_quota_project utility function in auth.py and the _create_bq_storage_client function are key additions enabling this functionality.

@shahar1 shahar1 force-pushed the gcp-set-quota-project-python branch from 642daed to 4f965fa Compare January 27, 2026 16:54
@shahar1
Copy link
Contributor Author

shahar1 commented Jan 27, 2026

/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 valuable feature to specify a quota_project_id for BigQuery read operations, which will be very useful for managing billing and quotas. The implementation is well-structured and includes comprehensive tests. I've identified a couple of areas for improvement: a pre-existing bug in BigQueryWrapper initialization that could lead to runtime errors, a case of silent error handling that should be improved with logging, and a weak assertion in a test that could be strengthened.

@shahar1 shahar1 force-pushed the gcp-set-quota-project-python branch 2 times, most recently from cfc3c60 to e021f8b Compare January 27, 2026 17:59
@shahar1 shahar1 force-pushed the gcp-set-quota-project-python branch from e021f8b to 1d7d1cd Compare January 27, 2026 18:53
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.

1 participant