Skip to content

Commit

Permalink
Adding retry function
Browse files Browse the repository at this point in the history
  • Loading branch information
seanglynn-thrive committed May 10, 2022
1 parent bf1c110 commit 45d3e2d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion target_bigquery/db_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from target_bigquery.stream_ref_helper import StreamRefHelper
from target_bigquery import sql_utils

from google.api_core.future import polling
from google.cloud import bigquery
from google.cloud.bigquery import retry as bq_retry


logger = singer.get_logger()

PRECISION = 38
Expand Down Expand Up @@ -288,7 +293,9 @@ def to_query_parameter(value):
queries = [query]

logger.info("TARGET_BIGQUERY - Running query: {}".format(query))
query_job = self.client.query(';\n'.join(queries), job_config=job_config)

query_job = self.client.query(';\n'.join(queries), job_config=job_config, retry=bq_retry.DEFAULT_RETRY)
query_job._retry = polling.DEFAULT_RETRY
query_job.result()

return query_job
Expand Down Expand Up @@ -460,6 +467,7 @@ def create_schema_if_not_exists(self):
self.grant_privilege(schema, self.grantees, self.grant_usage_on_schema)
except Conflict:
# Already exists.

pass

# pylint: disable=no-self-use
Expand Down

0 comments on commit 45d3e2d

Please sign in to comment.