nehsyc commented on a change in pull request #14033:
URL: https://github.com/apache/beam/pull/14033#discussion_r581564052
##########
File path: sdks/python/apache_beam/io/gcp/bigquery.py
##########
@@ -1254,13 +1257,20 @@ def process(self, element, *schema_side_inputs):
destination = bigquery_tools.get_hashable_destination(destination)
- row_and_insert_id = element[1]
- self._rows_buffer[destination].append(row_and_insert_id)
- self._total_buffered_rows += 1
- if len(self._rows_buffer[destination]) >= self._max_batch_size:
+ if not self.with_batched_input:
+ row_and_insert_id = element[1]
+ self._rows_buffer[destination].append(row_and_insert_id)
+ self._total_buffered_rows += 1
+ if len(self._rows_buffer[destination]) >= self._max_batch_size:
+ return self._flush_batch(destination)
+ elif self._total_buffered_rows >= self._max_buffered_rows:
+ return self._flush_all_batches()
+ else:
+ # The input is already batched per destination, flush the rows now.
+ batched_rows = element[1]
+ for row in batched_rows:
+ self._rows_buffer[destination].append(row)
Review comment:
Neat!
----------------------------------------------------------------
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]