@@ -5311,6 +5311,36 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails(self):
53115311 with pytest .raises (DataLoss , match = "we lost your job, sorry" ):
53125312 client .query ("SELECT 1;" , job_id = None )
53135313
5314+ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails_no_retries (self ):
5315+ from google .api_core .exceptions import Conflict
5316+ from google .api_core .exceptions import DataLoss
5317+ from google .cloud .bigquery .job import QueryJob
5318+
5319+ creds = _make_credentials ()
5320+ http = object ()
5321+ client = self ._make_one (project = self .PROJECT , credentials = creds , _http = http )
5322+
5323+ job_create_error = Conflict ("Job already exists." )
5324+ job_begin_patcher = mock .patch .object (
5325+ QueryJob , "_begin" , side_effect = job_create_error
5326+ )
5327+ get_job_patcher = mock .patch .object (
5328+ client , "get_job" , side_effect = DataLoss ("we lost your job, sorry" )
5329+ )
5330+
5331+ with job_begin_patcher , get_job_patcher :
5332+ # If get job request fails but supposedly there does exist a job
5333+ # with this ID already, raise the exception explaining why we
5334+ # couldn't recover the job.
5335+ with pytest .raises (DataLoss , match = "we lost your job, sorry" ):
5336+ client .query (
5337+ "SELECT 1;" ,
5338+ job_id = None ,
5339+ # Explicitly test with no retries to make sure those branches are covered.
5340+ retry = None ,
5341+ job_retry = None ,
5342+ )
5343+
53145344 def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404 (self ):
53155345 """Regression test for https://github.com/googleapis/python-bigquery/issues/2134
53165346
0 commit comments