Skip to content

Commit 09cc1df

Browse files
authored
fix: raise most recent exception when not able to fetch query job after starting the job (#1362)
* fix: raise most recent exception when not able to fetch query job after starting the job Towards internal issue 247809965 * update unit test * revert most changes to the test and explain why we're looking for a different exception from the original 'conflict'
1 parent d2b2c96 commit 09cc1df

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

google/cloud/bigquery/_job_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def do_query():
105105
timeout=timeout,
106106
)
107107
except core_exceptions.GoogleAPIError: # (includes RetryError)
108-
raise create_exc
108+
raise
109109
else:
110110
return query_job
111111
else:

tests/unit/test_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5092,12 +5092,14 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails(self):
50925092
QueryJob, "_begin", side_effect=job_create_error
50935093
)
50945094
get_job_patcher = mock.patch.object(
5095-
client, "get_job", side_effect=DataLoss("we lost yor job, sorry")
5095+
client, "get_job", side_effect=DataLoss("we lost your job, sorry")
50965096
)
50975097

50985098
with job_begin_patcher, get_job_patcher:
5099-
# If get job request fails, the original exception should be raised.
5100-
with pytest.raises(Conflict, match="Job already exists."):
5099+
# If get job request fails but supposedly there does exist a job
5100+
# with this ID already, raise the exception explaining why we
5101+
# couldn't recover the job.
5102+
with pytest.raises(DataLoss, match="we lost your job, sorry"):
51015103
client.query("SELECT 1;", job_id=None)
51025104

51035105
def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_succeeds(self):

0 commit comments

Comments
 (0)