Repository navigation
fix(sqlalchemy-bigquery): resolve project before create_job_config - #19201
Open
julianxu-goog wants to merge 2 commits into
Open
julianxu-goog wants to merge 2 commits into
julianxu-goog wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the create_connect_args method in sqlalchemy_bigquery/base.py to defer the creation of the default query job configuration until after the BigQuery client is initialized. This ensures that the project_id resolved from explicit credentials takes precedence over ambient Application Default Credentials (ADC) when constructing the job configuration. Additionally, several unit tests have been added to verify this behavior and prevent regressions. I have no further feedback to provide as the changes are well-implemented and thoroughly tested.
- Handle `user_supplied_client` in `BigQueryDialect.create_connect_args` before calling `create_job_config`, avoiding unnecessary ambient `google.auth.default()` calls when a dataset is present in the URL. - Create `bigquery.Client` and resolve `self.project_id` and `self.billing_project_id` from `client.project` before constructing `default_query_job_config` so explicit credentials (`credentials_info`, `credentials_path`, `credentials_base64`) with `bigquery:///dataset` do not fall back to host ambient ADC or set `dataset_project_id=None`. - Add unit tests covering explicit credentials with default datasets, `billing_project_id`, `user_supplied_client=true`, and direct `create_job_config()` fallback. Fixes internal issue b/581921313
julianxu-goog
force-pushed
the
fix/sqlalchemy-bigquery-ambient-project-dataset
branch
from
November 25, 2026 19:04
80301b7 to
09dca11
Compare
julianxu-goog
marked this pull request as ready for review
November 25, 2026 20:02
julianxu-goog
requested review from
sycai and
tswast
and removed request for
a team
November 25, 2026 20:02
sycai
reviewed
Dec 2, 2026
sycai
left a comment
Contributor
There was a problem hiding this comment.
Overall LGTM. I have one style nit that needs to be addressed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve the BigQuery client's project before calling
BigQueryDialect.create_job_configincreate_connect_args:Return early on
user_supplied_clientbefore callingcreate_job_config, avoiding an unnecessarygoogle.auth.default()lookup when the URL includes a dataset.Create the
bigquery.Clientand populateself.project_id/self.billing_project_idfromclient.projectbefore callingself.create_job_config(provided_job_config)and assigningclient.default_query_job_config. When connecting withbigquery:///datasetand explicit credentials (credentials_info,credentials_path, orcredentials_base64),default_datasetnow uses the explicit credentials' project rather than host ambient ADC (and combiningbigquery:///datasetwithbilling_project_idno longer emitsConnectionProperty(key="dataset_project_id", value=None)).Add unit tests covering explicit credentials (
credentials_info,credentials_path,credentials_base64) withbigquery:///dataset,billing_project_idwith local vs. remote datasets,user_supplied_client=truewith a dataset, and directcreate_job_config()fallback.Ensure the tests and linter pass (
nox -s lint,unit-3.14,unit-3.11,coverat 100% statement and branch coverage)Code coverage does not decrease
Fixes internal issue b/581921313