Skip to content

Commit c125ca3

Browse files
committed
PR feedback: use try/except to avoid failing when cancelling a job
1 parent 7a20897 commit c125ca3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sqlmesh/core/engine_adapter/bigquery.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,17 @@ def query_factory() -> Query:
189189
def close(self) -> t.Any:
190190
# Cancel all pending query jobs to avoid them becoming orphan, e.g., due to interrupts
191191
for query_job in self._query_jobs:
192-
if not self._db_call(query_job.done):
193-
self._db_call(query_job.cancel)
192+
try:
193+
if not self._db_call(query_job.done):
194+
self._db_call(query_job.cancel)
195+
except Exception as ex:
196+
logger.debug(
197+
"Failed to cancel BigQuery job: https://console.cloud.google.com/bigquery?project=%s&j=bq:%s:%s. %s",
198+
self._query_job.project,
199+
self._query_job.location,
200+
self._query_job.job_id,
201+
str(ex),
202+
)
194203

195204
self._query_jobs.clear()
196205
return super().close()

0 commit comments

Comments
 (0)