Fix Bigquery ADC diff projectid (#7935)

This commit is contained in:
Ayush Shah 2022-10-04 19:58:17 +05:30 committed by GitHub
parent c932b3bf92
commit ad53c509ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -358,18 +358,16 @@ def _(connection: BigQueryConnection):
_, project_id = auth.default()
if isinstance(connection.credentials.gcsConfig, GCSValues):
has_project_id = hasattr(connection.credentials.gcsConfig, "projectId")
if not project_id:
if has_project_id:
project_id = connection.credentials.gcsConfig.projectId
return f"{connection.scheme.value}://{connection.credentials.gcsConfig.projectId or ''}"
else:
if has_project_id and not hasattr(
connection.credentials.gcsConfig, "privateKey"
if (
not connection.credentials.gcsConfig.privateKey
and connection.credentials.gcsConfig.projectId
):
# Setting environment variable based on project id given by user / set in ADC
project_id = connection.credentials.gcsConfig.projectId
os.environ["GOOGLE_CLOUD_PROJECT"] = project_id
os.environ["GOOGLE_CLOUD_PROJECT"] = project_id
return f"{connection.scheme.value}://{project_id}"
return f"{connection.scheme.value}://"