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,14 +358,12 @@ def _(connection: BigQueryConnection):
_, project_id = auth.default() _, project_id = auth.default()
if isinstance(connection.credentials.gcsConfig, GCSValues): if isinstance(connection.credentials.gcsConfig, GCSValues):
has_project_id = hasattr(connection.credentials.gcsConfig, "projectId")
if not project_id: if not project_id:
if has_project_id: return f"{connection.scheme.value}://{connection.credentials.gcsConfig.projectId or ''}"
project_id = connection.credentials.gcsConfig.projectId
else: else:
if has_project_id and not hasattr( if (
connection.credentials.gcsConfig, "privateKey" not connection.credentials.gcsConfig.privateKey
and connection.credentials.gcsConfig.projectId
): ):
# Setting environment variable based on project id given by user / set in ADC # Setting environment variable based on project id given by user / set in ADC
project_id = connection.credentials.gcsConfig.projectId project_id = connection.credentials.gcsConfig.projectId