Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bigquery/google/cloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,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:

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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 @@ -274,6 +274,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