Skip to content

Commit

Permalink
Merge pull request googleapis#2534 from tseaver/2511-bigquery-capture…
Browse files Browse the repository at this point in the history
…-query-when-loading-job-by-name

Capture 'query' attr when loading 'QueryJob' from JSON resource.
  • Loading branch information
tseaver authored Oct 12, 2016
2 parents 09078c1 + 6eaca10 commit 9c9c126
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,8 @@ def _scrub_local_properties(self, cleaned):
the client's project.
"""
configuration = cleaned['configuration']['query']

self.query = configuration['query']
dest_remote = configuration.get('destinationTable')

if dest_remote is None:
Expand Down
3 changes: 2 additions & 1 deletion bigquery/unit_tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,7 @@ def _verifyResourceProperties(self, job, resource):
self._verifyBooleanResourceProperties(job, config)
self._verifyIntegerResourceProperties(job, config)

self.assertEqual(job.query, config['query'])
if 'createDisposition' in config:
self.assertEqual(job.create_disposition,
config['createDisposition'])
Expand Down Expand Up @@ -1596,7 +1597,7 @@ def test_reload_w_bound_client(self):
RESOURCE = self._makeResource()
conn = _Connection(RESOURCE)
client = _Client(project=self.PROJECT, connection=conn)
job = self._makeOne(self.JOB_NAME, self.QUERY, client)
job = self._makeOne(self.JOB_NAME, None, client)

dataset = Dataset(DS_NAME, client)
table = Table(DEST_TABLE, dataset)
Expand Down

0 comments on commit 9c9c126

Please sign in to comment.