Skip to content

Commit 9a1e7bf

Browse files
committed
Passing project properly in BQSource
1 parent c329565 commit 9a1e7bf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sdks/python/apache_beam/io/gcp/bigquery.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,13 @@ def estimate_size(self):
743743
if (isinstance(self.table_reference, vp.ValueProvider) and
744744
self.table_reference.is_accessible()):
745745
table_ref = bigquery_tools.parse_table_reference(
746-
self.table_reference.get(), project=self.project)
746+
table_ref, project=self._get_project())
747747
elif isinstance(self.table_reference, vp.ValueProvider):
748748
# Size estimation is best effort. We return None as we have
749749
# no access to the table that we're querying.
750750
return None
751+
if not table_ref.projectId:
752+
table_ref.projectId = self._get_project()
751753
table = bq.get_table(
752754
table_ref.projectId, table_ref.datasetId, table_ref.tableId)
753755
return int(table.numBytes)
@@ -804,6 +806,9 @@ def split(self, desired_bundle_size, start_position=None, stop_position=None):
804806
self._setup_temporary_dataset(bq)
805807
self.table_reference = self._execute_query(bq)
806808

809+
if not self.table_reference.projectId:
810+
self.table_reference.projectId = self._get_project()
811+
807812
schema, metadata_list = self._export_files(bq)
808813
self.split_result = [
809814
self._create_source(metadata.path, schema)

sdks/python/apache_beam/io/gcp/bigquery_tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ def perform_extract_job(
784784
),
785785
jobReference=job_reference,
786786
))
787+
logging.info('Performing BigQuery extract job: %s', request)
787788
response = self.client.jobs.Insert(request)
788789
return response.jobReference
789790

0 commit comments

Comments
 (0)