Skip to content

Commit

Permalink
[BEAM-12445] Handle none bq_client
Browse files Browse the repository at this point in the history
  • Loading branch information
angoenka committed Jul 20, 2021
1 parent c499c49 commit 6a95009
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sdks/python/apache_beam/io/gcp/bigquery_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,17 @@ def _insert_all_rows(

started_millis = int(time.time() * 1000)
try:
table_ref = gcp_bigquery.DatasetReference(project_id,
dataset_id).table(table_id)
table_ref_str = '%s.%s.%s' % (project_id, dataset_id, table_id)
errors = self.gcp_bq_client.insert_rows_json(
table_ref, json_rows=rows, row_ids=insert_ids, skip_invalid_rows=True)
table_ref_str,
json_rows=rows,
row_ids=insert_ids,
skip_invalid_rows=True)
if not errors:
service_call_metric.call('ok')
for insert_error in errors:
service_call_metric.call(insert_error['errors'][0])
else:
for insert_error in errors:
service_call_metric.call(insert_error['errors'][0])
except HttpError as e:
service_call_metric.call(e)

Expand Down

0 comments on commit 6a95009

Please sign in to comment.