Commit 56a563b 1 parent 414dc54 commit 56a563b Copy full SHA for 56a563b
File tree 1 file changed +17
-1
lines changed
metadata-ingestion/src/datahub/ingestion/source/bigquery_v2
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
from google .api_core import retry
8
8
from google .cloud import bigquery , datacatalog_v1 , resourcemanager_v3
9
+ from google .cloud .bigquery import retry as bq_retry
9
10
from google .cloud .bigquery .table import (
10
11
RowIterator ,
11
12
TableListItem ,
@@ -155,8 +156,23 @@ def __init__(
155
156
self .datacatalog_client = datacatalog_client
156
157
157
158
def get_query_result (self , query : str ) -> RowIterator :
159
+ def _should_retry (exc : BaseException ) -> bool :
160
+ logger .debug (f"Exception occured for job query. Reason: { exc } " )
161
+ # Jobs sometimes fail with transient errors.
162
+ # This is not currently handled by the python-bigquery client.
163
+ # https://github.com/googleapis/python-bigquery/issues/23
164
+ return "Retrying the job may solve the problem" in str (exc )
165
+
158
166
logger .debug (f"Query : { query } " )
159
- resp = self .bq_client .query (query )
167
+ resp = self .bq_client .query (
168
+ query ,
169
+ job_retry = retry .Retry (
170
+ predicate = lambda exc : (
171
+ bq_retry .DEFAULT_JOB_RETRY ._predicate (exc ) or _should_retry (exc )
172
+ ),
173
+ deadline = bq_retry .DEFAULT_JOB_RETRY ._deadline ,
174
+ ),
175
+ )
160
176
return resp .result ()
161
177
162
178
def get_projects (self , max_results_per_page : int = 100 ) -> List [BigqueryProject ]:
You can’t perform that action at this time.
0 commit comments