Title: BigQuery: Client.query modifies job_config object · Issue #9727 · googleapis/google-cloud-python · GitHub
Open Graph Title: BigQuery: Client.query modifies job_config object · Issue #9727 · googleapis/google-cloud-python
X Title: BigQuery: Client.query modifies job_config object · Issue #9727 · googleapis/google-cloud-python
Description: Steps to reproduce Create a QueryJobConfig object. Pass the object to the Client.query method. Observe that the configuration object has changed. Code example from google.cloud import bigquery client = bigquery.Client() config = bigquery...
Open Graph Description: Steps to reproduce Create a QueryJobConfig object. Pass the object to the Client.query method. Observe that the configuration object has changed. Code example from google.cloud import bigquery clie...
X Description: Steps to reproduce Create a QueryJobConfig object. Pass the object to the Client.query method. Observe that the configuration object has changed. Code example from google.cloud import bigquery clie...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/9727
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BigQuery: Client.query modifies job_config object","articleBody":"#### Steps to reproduce\r\n\r\n 1. Create a `QueryJobConfig` object.\r\n 2. Pass the object to the `Client.query` method.\r\n 3. Observe that the configuration object has changed.\r\n\r\n#### Code example\r\n\r\n```python\r\nfrom google.cloud import bigquery\r\n\r\nclient = bigquery.Client()\r\nconfig = bigquery.QueryJobConfig(dry_run=True)\r\njob = client.query(\r\n \"\"\"\r\n SELECT name, SUM(number) AS total_people\r\n FROM `bigquery-public-data.usa_names.usa_1910_current`\r\n GROUP BY name\r\n \"\"\",\r\n job_config=config\r\n)\r\nprint(job.total_bytes_processed)\r\n\r\nconfig.dry_run = False\r\njob = client.query(\r\n \"\"\"\r\n SELECT name, SUM(number) AS total_people\r\n FROM `bigquery-public-data.usa_names.usa_1910_current`\r\n GROUP BY name\r\n \"\"\",\r\n job_config=config\r\n)\r\njob.result()\r\n```\r\n\r\n#### Stack trace\r\n```\r\n---------------------------------------------------------------------------\r\nBadRequest Traceback (most recent call last)\r\n\u003cipython-input-17-97f4f20faa6a\u003e in \u003cmodule\u003e\r\n----\u003e 1 job.result()\r\n\r\n~/miniconda3/envs/scratch/lib/python3.7/site-packages/google/cloud/bigquery/job.py in result(self, timeout, page_size, retry, max_results)\r\n 2937 \"\"\"\r\n 2938 try:\r\n-\u003e 2939 super(QueryJob, self).result(timeout=timeout)\r\n 2940 \r\n 2941 # Return an iterator instead of returning the job.\r\n\r\n~/miniconda3/envs/scratch/lib/python3.7/site-packages/google/cloud/bigquery/job.py in result(self, timeout, retry)\r\n 732 self._begin(retry=retry)\r\n 733 # TODO: modify PollingFuture so it can pass a retry argument to done().\r\n--\u003e 734 return super(_AsyncJob, self).result(timeout=timeout)\r\n 735 \r\n 736 def cancelled(self):\r\n\r\n~/miniconda3/envs/scratch/lib/python3.7/site-packages/google/api_core/future/polling.py in result(self, timeout)\r\n 125 # pylint: disable=raising-bad-type\r\n 126 # Pylint doesn't recognize that this is valid in this case.\r\n--\u003e 127 raise self._exception\r\n 128 \r\n 129 return self._result\r\n\r\nBadRequest: 400 Cannot explicitly modify anonymous table swast-scratch:_def2aa82a75fc33513bfb65968607e1f49148f83.anon561d4b35377f56c5960a4a49be253d3c90c120db\r\n\r\n(job ID: 2692472c-1213-4716-8393-d9c49fd7b678)\r\n\r\n -----Query Job SQL Follows----- \r\n\r\n | . | . | . | . | . |\r\n 1:\r\n 2: SELECT name, SUM(number) AS total_people\r\n 3: FROM `bigquery-public-data.usa_names.usa_1910_current`\r\n 4: GROUP BY name\r\n 5: \r\n | . | . | . | . | . |\r\n```\r\n\r\nWhen you run a job, the configuration object may be modified. In this example, it sets the destination table. It is unexpected that the original Python object would be modified.\r\n\r\nI propose that the `query` (and other \"job\" methods on client) be updated to make a deep copy of the the `job_config` argument before passing it on to the job constructor.","author":{"url":"https://github.com/tswast","@type":"Person","name":"tswast"},"datePublished":"2019-11-11T19:25:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/9727/google-cloud-python/issues/9727"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:39b0249a-a730-0c0b-3a55-de3e0a9f81cc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9FAC:18EF1B:1541903:1D4CD99:6A4EA805 |
| html-safe-nonce | 087716c13609b03e6a2773264aa6cc4d69938bfdd0283f0aaa94eda160026899 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkFDOjE4RUYxQjoxNTQxOTAzOjFENENEOTk6NkE0RUE4MDUiLCJ2aXNpdG9yX2lkIjoiNzk2Njc4NDA2ODA0OTA4NjQ2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5c9b1623f4450d711686e9dc717d914aa36ed071609f21d0f8b0379c83b215e3 |
| hovercard-subject-tag | issue:521141754 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/9727/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6b9e54398446844943113c66360dce04b8c9a08f48b1e8b3e2a29a6e048d889f/googleapis/google-cloud-python/issues/9727 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6b9e54398446844943113c66360dce04b8c9a08f48b1e8b3e2a29a6e048d889f/googleapis/google-cloud-python/issues/9727 |
| og:image:alt | Steps to reproduce Create a QueryJobConfig object. Pass the object to the Client.query method. Observe that the configuration object has changed. Code example from google.cloud import bigquery clie... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tswast |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6a744804e8e70f97b4d5a18a94dcc63db22f97a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width