Skip to content

[Gemini] Add compatibility classes between apitools client and modern bq client - #39998

Open
jrmccluskey wants to merge 4 commits into
apache:masterfrom
jrmccluskey:compatClasses
Open

[Gemini] Add compatibility classes between apitools client and modern bq client#39998
jrmccluskey wants to merge 4 commits into
apache:masterfrom
jrmccluskey:compatClasses

Conversation

@jrmccluskey

Copy link
Copy Markdown
Contributor

Creates compatibility shims between generated BigQuery classes and the modern google-cloud-bigquery client to be used in migrating support over to the modern client.

Master PR - #39889


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.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @tvalentyn 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).

@jrmccluskey

Copy link
Copy Markdown
Contributor Author

R: @damccorm

This should be good to take a run at, had to track down a docs precommit problem. Going to put improving the readability of the output of that test suite on my to-do list.

@github-actions

github-actions Bot commented Sep 3, 2026

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

@damccorm damccorm 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.

Left a couple of preliminary comments to make sure I'm understanding the approach broadly, thanks

"TableReference"):
TableReference = apitools_bigquery.TableReference
DatasetReference = getattr(
apitools_bigquery, "DatasetReference", None) or _DatasetReferenceCompat

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.

If apitools is imported, will we ever need this fallback? Same thing applies elsewhere

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.

Yeah that assignment block was just redundant, e.g. the apitools library is at present always available in Beam as a core dependency. Cleaned that up.

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.

Well, correction in that the apitools library is a GCP extras dependency. Need some extra massaging to make the import clean for unit tests in an environment where apitools itself isn't installed.

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.

Fixing the root cause of the confusion here separately in #40082, will also probably see if this antipattern exists elsewhere in the code base

self.f = f or []


if apitools_bigquery is not None and hasattr(apitools_bigquery,

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.

Who do we expect to need this fallback? IIUC, it would just be people who depend on the internal generated BQ client, but we don't expect "normal" users to use it. Is that right? If so, I think we should force users to opt in to the fallback somehow - this will both alert them that the deprecated module will eventually go away and that they're in a potentially unsafe mode.

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.

These classes should only really be needed if the old client and types are being used, yes. The intent is to throw a warning on import of the generated client and types (this is shown in the master PR and will be done in a follow-up) but if we wanted to make a really explicit opt-in here we could require some sort of arg?

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.

The intent is to throw a warning on import of the generated client and types (this is shown in the master PR and will be done in a follow-up) but if we wanted to make a really explicit opt-in here we could require some sort of arg?

Yeah, I think we should do this (and still warn if they set it). This could probably just be an environment variable the user adds directly before the import since actually plumbing through an arg seems hard.

My thought here, though, is basically:

  1. This module is clearly internal. I think we're within our "rights" to make a breaking change
  2. This module will go away, and the sooner folks start to move off of it the better.
  3. At the same time, it is helpful to provide a smooth upgrade path so that folks can address this independently of the beam version bump
  4. Warnings are easy to miss/ignore, while a forced action with an exception at least makes it clear that (a) this is potentially unsafe, and (b) this will go away.

As much as possible, I want to avoid users depending on this without knowing (since I don't think it is guaranteed to be a perfect 1:1 replacement)

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.

Implicit here is that I have a hard time trusting this shim. I expect it works in the happy path cases, but I doubt we're replicating behavior perfectly.

FWIW, the rest of the PR LGTM

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.

2 participants