From 9980657e31ea80770e2f2a5485b2a66f71cc003d Mon Sep 17 00:00:00 2001 From: Colin Rogers <111200756+colin-rogers-dbt@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:32:20 -0700 Subject: [PATCH] Preserve nicely formatted timeout exception (#1187) * use dynamic schema in test_grant_access_to.py * use dynamic schema in test_grant_access_to.py * revert setup * Add descriptive error message on query timeout * Add descriptive error message on query timeout (cherry picked from commit b62ce7469a47de4e1f526fc551817b3e0919ddb2) --- dbt/adapters/bigquery/connections.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dbt/adapters/bigquery/connections.py b/dbt/adapters/bigquery/connections.py index 68fc10372..3e7700d54 100644 --- a/dbt/adapters/bigquery/connections.py +++ b/dbt/adapters/bigquery/connections.py @@ -1,3 +1,4 @@ +from concurrent.futures import TimeoutError import json import re from contextlib import contextmanager @@ -736,9 +737,12 @@ def _query_and_results( logger.debug( self._bq_job_link(query_job.location, query_job.project, query_job.job_id) ) - - iterator = query_job.result(max_results=limit, timeout=job_execution_timeout) - return query_job, iterator + try: + iterator = query_job.result(max_results=limit, timeout=job_execution_timeout) + return query_job, iterator + except TimeoutError: + exc = f"Operation did not complete within the designated timeout of {job_execution_timeout} seconds." + raise TimeoutError(exc) def _retry_and_handle(self, msg, conn, fn): """retry a function call within the context of exception_handler."""