Skip to content

Update Bigquery Client#38950

Open
tarun-google wants to merge 2 commits into
apache:masterfrom
tarun-google:update_client
Open

Update Bigquery Client#38950
tarun-google wants to merge 2 commits into
apache:masterfrom
tarun-google:update_client

Conversation

@tarun-google

Copy link
Copy Markdown
Contributor

Prerequisite to fix #34075

Updated with the script

gen_client --discovery_url="https://www.googleapis.com/discovery/v1/apis/bigquery/v2/rest" --overwrite --outdir=sdks/python/apache_beam/io/gcp/internal/clients/bigquery --root_package=apache_beam.io.gcp.internal.clients.bigquery client

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
Copy Markdown
Contributor

Summary of Changes

Hello, 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 updates the BigQuery client library within the Apache Beam codebase by regenerating it from the latest discovery document. The primary purpose of this change is to ensure the client remains synchronized with the current BigQuery API surface, incorporating recent updates to endpoint paths and adding missing documentation regarding required IAM permissions for specific operations.

Highlights

  • Client Regeneration: Regenerated the BigQuery client library using the standard gen_client script to ensure alignment with the latest API discovery document.
  • API Configuration Updates: Updated API method configurations, including the addition of flat_path definitions and the transition to using expanded path parameters for better compatibility.
  • IAM Documentation: Added detailed IAM permission requirements to the docstrings of various API methods to improve developer clarity and security auditing.
  • New API Methods: Introduced new API methods such as dataset undeletion, job deletion, and expanded row access policy management.
New Features

🧠 You can now enable Memory (public preview) 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 the 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 counterproductive. 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.

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.

@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 updates the BigQuery V2 client, modifying API paths, adding new service methods (such as row access policies and dataset undeletion), and updating authentication scopes and base URLs. Feedback on these changes highlights several critical issues: the removal of the bigquery.readonly scope and the replacement of client credentials with placeholders may break authentication, while the use of Python 2-style super() calls and extremely long lines violates modern Python 3 standards and PEP 8 guidelines.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

'https://www.googleapis.com/auth/devstorage.read_only',
'https://www.googleapis.com/auth/devstorage.read_write'
]
_SCOPES = ['https://www.googleapis.com/auth/bigquery', 'https://www.googleapis.com/auth/bigquery.insertdata', 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-platform.read-only', 'https://www.googleapis.com/auth/devstorage.full_control', 'https://www.googleapis.com/auth/devstorage.read_only', 'https://www.googleapis.com/auth/devstorage.read_write']

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.

high

The scope 'https://www.googleapis.com/auth/bigquery.readonly' has been removed from _SCOPES. If this client is used in environments or with credentials that only have read-only access to BigQuery, removing this scope may cause authentication or authorization failures.\n\nAdditionally, this line is extremely long (345 characters), which violates PEP 8 line length limits. Please format this list across multiple lines to maintain readability.

  _SCOPES = [\n      'https://www.googleapis.com/auth/bigquery',\n      'https://www.googleapis.com/auth/bigquery.insertdata',\n      'https://www.googleapis.com/auth/bigquery.readonly',\n      'https://www.googleapis.com/auth/cloud-platform',\n      'https://www.googleapis.com/auth/cloud-platform.read-only',\n      'https://www.googleapis.com/auth/devstorage.full_control',\n      'https://www.googleapis.com/auth/devstorage.read_only',\n      'https://www.googleapis.com/auth/devstorage.read_write'\n  ]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +37 to +38
_CLIENT_ID = 'CLIENT_ID'
_CLIENT_SECRET = 'CLIENT_SECRET'

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.

high

The OAuth _CLIENT_ID and _CLIENT_SECRET have been replaced with the placeholder strings 'CLIENT_ID' and 'CLIENT_SECRET'. If any user flows or authentication mechanisms in Beam rely on these default client credentials (for example, when performing interactive user authentication), this change will break them.\n\nIf the generator script gen_client overrode these values, please consider passing the correct client ID and secret to the generator script (using --client_id and --client_secret flags) or restoring the original values.

  _CLIENT_ID = '1042881264118.apps.googleusercontent.com'\n  _CLIENT_SECRET = 'x_Tw5K8nnjoRAqULM9PFAC2b'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are these secrets? why are we publishing them?

Comment thread sdks/python/apache_beam/io/gcp/internal/clients/bigquery/bigquery_v2_client.py Outdated
@github-actions

Copy link
Copy Markdown
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

@tarun-google

Copy link
Copy Markdown
Contributor Author

Run Python_ML PreCommit 3.13

@tarun-google

Copy link
Copy Markdown
Contributor Author

R: @Abacn

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

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.

[Feature Request]: Request to use BASIC enum when calling tables.get() in BigQuery

1 participant