Skip to content
Merged
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
13 changes: 13 additions & 0 deletions sdks/python/apache_beam/io/gcp/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,16 @@ def __init__(
self._step_name = step_name
self._source_uuid = unique_id

def _get_project(self):
"""Returns the project that queries and exports will be billed to."""
if self.pipeline_options:
project = self.pipeline_options.view_as(GoogleCloudOptions).project
if isinstance(project, vp.ValueProvider):
project = project.get()
if project:
return project
return self.project

def _get_parent_project(self):
"""Returns the project that will be billed."""
if self.temp_table:
Expand Down Expand Up @@ -1164,6 +1174,9 @@ def split(self, desired_bundle_size, start_position=None, stop_position=None):
self._setup_temporary_dataset(bq)
self.table_reference = self._execute_query(bq)

if not self.table_reference.projectId:
self.table_reference.projectId = self._get_project()

requested_session = bq_storage.types.ReadSession()
requested_session.table = 'projects/{}/datasets/{}/tables/{}'.format(
self.table_reference.projectId,
Expand Down
Loading
Loading