Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

class BigQueryConnectionProperties(DataSourceConnectionProperties, ABC):
project_id: Optional[str] = Field(None, description="BigQuery project ID")
execution_project: Optional[str] = Field(
None, description="BigQuery execution/billing project ID. If not set, uses project_id"
)
storage_project_id: Optional[str] = Field(None, description="BigQuery storage project ID")
location: Optional[str] = Field(None, description="BigQuery location")
client_options: Optional[dict] = Field(None, description="Client options")
Expand Down Expand Up @@ -115,6 +118,18 @@ def _load_optional_impersonated_credentials(self, config: BigQueryConnectionProp
def _apply_optional_params(self, config: BigQueryConnectionProperties):
# Users can optionally overwrite in the connection properties
self.project_id = config.project_id if config.project_id else self.project_id
# execution_project is the project that will be billed for queries (aka billing project)
# If not set, defaults to project_id
if config.execution_project:
self.execution_project = config.execution_project
else:
# Ensure project_id is set before using it as fallback
if not self.project_id:
raise ValueError(
"Either execution_project or project_id must be set. "
"When using context authentication, ensure your default credentials include a project ID."
)
self.execution_project = self.project_id
self.location = config.location
self.client_options = config.client_options

Expand All @@ -137,7 +152,7 @@ def _create_connection(
)
default_query_job_config = bigquery.QueryJobConfig(labels=self.labels)
self.client = bigquery.Client(
project=self.project_id,
project=self.execution_project,
credentials=self.credentials,
default_query_job_config=default_query_job_config,
client_info=client_info,
Expand Down
Loading