You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "ahmedabu98 (via GitHub)" <gi...@apache.org> on 2023/07/05 14:43:16 UTC
[GitHub] [beam] ahmedabu98 commented on a diff in pull request #24979: Respect BigQuery insert byte size limits
ahmedabu98 commented on code in PR #24979:
URL: https://github.com/apache/beam/pull/24979#discussion_r1253219275
##########
sdks/python/apache_beam/io/gcp/bigquery.py:
##########
@@ -1515,11 +1526,41 @@ def process(self, element, *schema_side_inputs):
if not self.with_batched_input:
row_and_insert_id = element[1]
+ row_byte_size = get_deep_size(row_and_insert_id)
+
+ # send large rows that exceed BigQuery insert limits to DLQ
+ if row_byte_size >= self.max_insert_payload_size:
+ row_mb_size = row_byte_size / 1_000_000
+ max_mb_size = self.max_insert_payload_size / 1_000_000
+ error = (
+ f"Received row with size {row_mb_size}MB that exceeds "
+ f"the maximum insert payload size set ({max_mb_size}MB).")
+ return [
+ pvalue.TaggedOutput(
+ BigQueryWriteFn.FAILED_ROWS_WITH_ERRORS,
+ GlobalWindows.windowed_value(
+ (destination, row_and_insert_id[0], error))),
+ pvalue.TaggedOutput(
+ BigQueryWriteFn.FAILED_ROWS,
+ GlobalWindows.windowed_value(
+ (destination, row_and_insert_id[0])))
+ ]
+
+ buffer_byte_size_with_row = (
+ row_byte_size if not self._rows_buffer[destination] else
+ row_byte_size + get_deep_size(self._rows_buffer[destination]))
Review Comment:
Done, PTAL
--
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.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org