Skip to content

Commit 5238b42

Browse files
committed
Check running status via 'job' property.
If the '_job' attribute is not set, but we have a 'jobId' in our properties, we still don't want to re-run the query. Closes #3003.
1 parent 9619004 commit 5238b42

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

bigquery/google/cloud/bigquery/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def run(self, client=None):
351351
:param client: the client to use. If not passed, falls back to the
352352
``client`` stored on the current dataset.
353353
"""
354-
if self._job is not None:
354+
if self.job is not None:
355355
raise ValueError("Query job is already running.")
356356

357357
client = self._require_client(client)

bigquery/unit_tests/test_query.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ def test_run_w_already_has_job(self):
274274
with self.assertRaises(ValueError):
275275
query.run()
276276

277+
def test_run_w_already_has_job_in_properties(self):
278+
JOB_ID = 'JOB_ID'
279+
conn = _Connection()
280+
client = _Client(project=self.PROJECT, connection=conn)
281+
query = self._make_one(self.QUERY, client)
282+
query._properties['jobReference'] = {'jobId': JOB_ID}
283+
with self.assertRaises(ValueError):
284+
query.run()
285+
277286
def test_run_w_bound_client(self):
278287
PATH = 'projects/%s/queries' % self.PROJECT
279288
RESOURCE = self._makeResource(complete=False)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy