Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Destination tables are no-longer removed by create_job #891

Merged
merged 2 commits into from
Aug 23, 2021
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: 0 additions & 2 deletions google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1937,7 +1936,6 @@ def create_job(
)
elif "query" in job_config:
copy_config = copy.deepcopy(job_config)
_del_sub_prop(copy_config, ["query", "destinationTable"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are no longer removing the property, we could just collapse this whole clause into:

        elif "query" in job_config:
            query_job_config = google.cloud.bigquery.job.QueryJobConfig.from_api_repr(
                job_config
            )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. #893

query_job_config = google.cloud.bigquery.job.QueryJobConfig.from_api_repr(
copy_config
)
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -2606,8 +2604,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",
Expand Down Expand Up @@ -2732,7 +2728,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()
Expand Down