pabloem commented on a change in pull request #13170:
URL: https://github.com/apache/beam/pull/13170#discussion_r528037127



##########
File path: sdks/python/apache_beam/io/gcp/bigquery_read_internal.py
##########
@@ -100,3 +127,258 @@ def process(self, unused_element, unused_signal, 
gcs_locations):
     )
 
     return main_output
+
+
+class _BigQueryReadSplit(beam.transforms.DoFn):
+  def __init__(
+      self,
+      options: PipelineOptions,
+      gcs_location: Union[str, ValueProvider] = None,
+      use_json_exports: bool = False,
+      bigquery_job_labels: Dict[str, str] = None,
+      step_name: str = None,
+      job_name: str = None,
+      unique_id: str = None,
+      kms_key: str = None,
+      project: str = None,
+      temp_dataset: Union[str, DatasetReference] = None):
+    self.options = options
+    self.use_json_exports = use_json_exports
+    self.gcs_location = gcs_location
+    self.bigquery_job_labels = bigquery_job_labels or {}
+    self._step_name = step_name
+    self._job_name = job_name or 'BQ_READ_SPLIT'
+    self._source_uuid = unique_id
+    self.kms_key = kms_key
+    self.project = project
+    self.temp_dataset = temp_dataset
+    self.bq_io_metadata = None
+
+  def display_data(self):
+    return {
+        'use_json_exports': str(self.use_json_exports),
+        'gcs_location': str(self.gcs_location),
+        'bigquery_job_labels': json.dumps(self.bigquery_job_labels),
+        'kms_key': str(self.kms_key),
+        'project': str(self.project),
+        'temp_dataset': str(self.temp_dataset)
+    }
+
+  def _get_temp_dataset(self):
+    if isinstance(self.temp_dataset, str):
+      return DatasetReference(
+          datasetId=self.temp_dataset, projectId=self._get_project())
+    else:
+      return self.temp_dataset
+
+  def process(self, element: 'ReadFromBigQueryRequest', *args,
+              **kwargs) -> Iterable[BoundedSource]:
+    bq = bigquery_tools.BigQueryWrapper(
+        temp_dataset_id=(
+            self._get_temp_dataset().datasetId if self._get_temp_dataset(

Review comment:
       hm this is a great catch Cham. I've changed this so we always use the 
same Dataset, and we just delete the temporary table. WDYT?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to