Repository navigation
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR adds support for custom BigQuery API endpoints and sovereign cloud universe domains via the --bigquery_endpoint pipeline option and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable, wiring them into both the apitools and google-cloud-bigquery clients. The implementation is clean, well-structured, and thoroughly covered by unit tests.
🔍 General Feedback
- The endpoint normalization logic in
_normalize_bigquery_roothandles trailing slashes,/bigquery/v2suffixes, and bare hostnames cleanly. - Passing the derived host from
api_urlto_HttpWithHeadersensuresx-goog-user-projectquota headers continue to work seamlessly against custom endpoints and TPC universe domains without leaking to OAuth token endpoints.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40675 +/- ##
==========================================
+ Coverage 80.04% 80.08% +0.03%
==========================================
Files 490 490
Lines 82916 83048 +132
==========================================
+ Hits 66373 66508 +135
+ Misses 16543 16540 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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). |
BigQueryWrapper always sent BigQuery REST calls to bigquery.googleapis.com, so it could not be used in Trusted Partner Cloud (TPC) or other universes. Add a --bigquery_endpoint option, matching Java's bigQueryEndpoint. The BigqueryV2 URL now comes from that option, then from GOOGLE_CLOUD_UNIVERSE_DOMAIN, then the default URL. The option is also passed to google.cloud.bigquery.Client, which reads the universe domain on its own when the option is unset. Workers fall back to the running pipeline's options.
Store the option as big_query_endpoint so it is serialized as beam:option:big_query_endpoint:v1, which Java maps to the bigQueryEndpoint option used by cross-language BigQuery transforms. Both --bigquery_endpoint and --big_query_endpoint, and both attribute names on BigQueryOptions, are accepted.
Part of #40569. Note that the BigQuery apitools clients are currently being deprecated (#39889)
Problem
BigQueryWrapper._bigquery_client()builds the apitoolsBigqueryV2client without aurl, so it falls back toBASE_URL = 'https://bigquery.googleapis.com/bigquery/v2/'. apitools does not readGOOGLE_CLOUD_UNIVERSE_DOMAIN, and Beam has no option to override the endpoint. As a result, BigQuery REST calls (tables, jobs, datasets) always go to the public endpoint. This makes BigQuery IO unusable in Trusted Partner Cloud (TPC) and other non-default universes.Changes
--bigquery_endpointoption inGoogleCloudOptions, the Python equivalent of Java'sBigQueryOptions.bigQueryEndpoint(Allow setting BigQuery endpoint #32153). It takes the root URL, e.g.https://bigquery.example.com. The input is normalized: a missing scheme defaults tohttps, and a trailing/or/bigquery/v2is stripped.BigqueryV2, in this order:--bigquery_endpointhttps://bigquery.<domain>whenGOOGLE_CLOUD_UNIVERSE_DOMAINis set to something other thangoogleapis.comStep 2 matches how
google-cloud-bigqueryresolves its endpoint, so both clients target the same universe.google.cloud.bigquery.Client(streaming inserts) getsclient_options={'api_endpoint': ...}when--bigquery_endpointis set, merged withquota_project_id. When the option is unset, the library resolves the endpoint itself, includingGOOGLE_CLOUD_UNIVERSE_DOMAIN.BigQueryWrapper()inside DoFns, the endpoint is read from the running pipeline's options viaRuntimeValueProvider.Not changed
BigQueryReadClient) does not use--bigquery_endpoint. It is served from a different host (bigquerystorage.<domain>), and the client library already readsGOOGLE_CLOUD_UNIVERSE_DOMAIN. Java does apply its option to the storage clients; this can be revisited if a separate storage endpoint option is needed.