Skip to content

Commit

Permalink
Merge pull request #3005 from tseaver/3003-bigquery-job_status_via_pr…
Browse files Browse the repository at this point in the history
…operty

Check running status via 'job' property.

Merging without waiting for the speech fix to land.
  • Loading branch information
tseaver committed Feb 13, 2017
2 parents 5d5c2f7 + 5238b42 commit ac612e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bigquery/google/cloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def run(self, client=None):
:param client: the client to use. If not passed, falls back to the
``client`` stored on the current dataset.
"""
if self._job is not None:
if self.job is not None:
raise ValueError("Query job is already running.")

client = self._require_client(client)
Expand Down
9 changes: 9 additions & 0 deletions bigquery/unit_tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,15 @@ def test_run_w_already_has_job(self):
with self.assertRaises(ValueError):
query.run()

def test_run_w_already_has_job_in_properties(self):
JOB_ID = 'JOB_ID'
conn = _Connection()
client = _Client(project=self.PROJECT, connection=conn)
query = self._make_one(self.QUERY, client)
query._properties['jobReference'] = {'jobId': JOB_ID}
with self.assertRaises(ValueError):
query.run()

def test_run_w_bound_client(self):
PATH = 'projects/%s/queries' % self.PROJECT
RESOURCE = self._makeResource(complete=False)
Expand Down

0 comments on commit ac612e6

Please sign in to comment.