From 1414c7775d997e0dd6609d007b6567260b4584ff Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Fri, 20 Aug 2021 16:46:43 -0400 Subject: [PATCH 1/2] feat: Destination tables are no-longer removed by create_job --- google/cloud/bigquery/client.py | 1 - tests/unit/test_client.py | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/google/cloud/bigquery/client.py b/google/cloud/bigquery/client.py index 1a826eb55..c242a6950 100644 --- a/google/cloud/bigquery/client.py +++ b/google/cloud/bigquery/client.py @@ -1937,7 +1937,6 @@ def create_job( ) elif "query" in job_config: copy_config = copy.deepcopy(job_config) - _del_sub_prop(copy_config, ["query", "destinationTable"]) query_job_config = google.cloud.bigquery.job.QueryJobConfig.from_api_repr( copy_config ) diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index bd07990b8..10305bff5 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -2606,8 +2606,6 @@ def _create_job_helper(self, job_config): } conn = client._connection = make_connection(RESOURCE) client.create_job(job_config=job_config) - if "query" in job_config: - _helpers._del_sub_prop(job_config, ["query", "destinationTable"]) conn.api_request.assert_called_once_with( method="POST", @@ -2732,7 +2730,7 @@ def test_create_job_query_config_w_rateLimitExceeded_error(self): } data_without_destination = { "jobReference": {"projectId": self.PROJECT, "jobId": mock.ANY}, - "configuration": {"query": {"query": query, "useLegacySql": False}}, + "configuration": configuration, } creds = _make_credentials() From 02864b002be66f494e979919cb88eac455c1892f Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Mon, 23 Aug 2021 08:26:54 -0600 Subject: [PATCH 2/2] Removed unused imports --- google/cloud/bigquery/client.py | 1 - tests/unit/test_client.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/google/cloud/bigquery/client.py b/google/cloud/bigquery/client.py index c242a6950..93ba2aa11 100644 --- a/google/cloud/bigquery/client.py +++ b/google/cloud/bigquery/client.py @@ -49,7 +49,6 @@ DEFAULT_CLIENT_INFO as DEFAULT_BQSTORAGE_CLIENT_INFO, ) -from google.cloud.bigquery._helpers import _del_sub_prop from google.cloud.bigquery._helpers import _get_sub_prop from google.cloud.bigquery._helpers import _record_field_to_json from google.cloud.bigquery._helpers import _str_or_none diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 10305bff5..458798afa 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -2594,8 +2594,6 @@ def test_delete_table_w_not_found_ok_true(self): conn.api_request.assert_called_with(method="DELETE", path=path, timeout=None) def _create_job_helper(self, job_config): - from google.cloud.bigquery import _helpers - creds = _make_credentials() http = object() client = self._make_one(project=self.PROJECT, credentials=creds, _http=http)