From 6eaca10232887e69a6b32ee5872cd959620e0ead Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Wed, 12 Oct 2016 13:05:14 -0400 Subject: [PATCH] Capture 'query' attr when loading 'QueryJob' from JSON resource. Closes: #2511. --- bigquery/google/cloud/bigquery/job.py | 2 ++ bigquery/unit_tests/test_job.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bigquery/google/cloud/bigquery/job.py b/bigquery/google/cloud/bigquery/job.py index b86f51c3fe18..d0155ca8b32e 100644 --- a/bigquery/google/cloud/bigquery/job.py +++ b/bigquery/google/cloud/bigquery/job.py @@ -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: diff --git a/bigquery/unit_tests/test_job.py b/bigquery/unit_tests/test_job.py index 2ac135c0e739..592d81910f59 100644 --- a/bigquery/unit_tests/test_job.py +++ b/bigquery/unit_tests/test_job.py @@ -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']) @@ -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)