Title: BigQuery python cli fails to change time, BUT does changes timezone for TIMESTAMP which leads to an incorrect time · Issue #476 · googleapis/python-bigquery · GitHub
Open Graph Title: BigQuery python cli fails to change time, BUT does changes timezone for TIMESTAMP which leads to an incorrect time · Issue #476 · googleapis/python-bigquery
X Title: BigQuery python cli fails to change time, BUT does changes timezone for TIMESTAMP which leads to an incorrect time · Issue #476 · googleapis/python-bigquery
Description: This code works with with the python package google-cloud-bigquery==2.2.0 but it does not work with this package google-cloud-bigquery==2.6.0 What you expected to happen: I expect the client library to take a datetime of '2017-11-01 04:0...
Open Graph Description: This code works with with the python package google-cloud-bigquery==2.2.0 but it does not work with this package google-cloud-bigquery==2.6.0 What you expected to happen: I expect the client librar...
X Description: This code works with with the python package google-cloud-bigquery==2.2.0 but it does not work with this package google-cloud-bigquery==2.6.0 What you expected to happen: I expect the client librar...
Opengraph URL: https://github.com/googleapis/python-bigquery/issues/476
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BigQuery python cli fails to change time, BUT does changes timezone for TIMESTAMP which leads to an incorrect time","articleBody":"This code works with with the python package\r\n **google-cloud-bigquery==2.2.0** \r\nbut it does not work with this package\r\n **google-cloud-bigquery==2.6.0**\r\n\r\nWhat you expected to happen:\r\n\r\nI expect the client library to take a datetime of\r\n '_2017-11-01 04:08 AM -07:00_' and convert it to\r\n '_2017-11-01 11:08 AM -00:00_' in big query. but instead it uploads it to\r\n '_2017-11-01 04:08 AM -00:00_'\r\n\r\nSteps to reproduce:\r\n```\r\nimport datetime\r\nfrom dateutil.tz import tzoffset\r\nfrom google.cloud.bigquery import SchemaField, Table\r\n\r\nschema = [SchemaField('c', 'TIMESTAMP', 'NULLABLE', None, (), None)] \r\nproblem_date = datetime.datetime(2017, 11, 1, 4, 8, tzinfo=tzoffset(None, -25200))\r\ntable_name = ‘my_test_table’\r\ndataset = \u003can existing dataset\u003e\r\n\r\nbigquery = bigquery.Client(credentials=\u003csomecreds\u003e, project=\u003courproj\u003e)\r\n\r\ndataset_ref = bigquery.dataset(dataset, project=\u003courproj\u003e)\r\ntable_ref = dataset_ref.table(table_name)\r\ntable = bigquery.create_table(Table(table_ref, schema=schema))\r\nerrors = bigquery.insert_rows(table, [[problem_date]])\r\n```\r\n\r\n#### Other info\r\n-------------------------------\r\nI worked with the google BigQuery team and here is their [feedback](https://issuetracker.google.com/issues/175849093).\r\nHello,\r\n\r\nI have been investigating the issue you described and it seems like this change of behaviour of the python client library was introduced in the version 2.5.0 [1] with the pull request #393 [2], whose objective was to fix a previous issue with floating points and timestamps in the method `insert_rows`.\r\n\r\nI have been able to reproduce your issue in new versions after 2.5.0 while it does not happen in the previous ones. The suggested way to proceed here would be to open an issue in the Github repository [3] so you can transmit your findings to the Engineering Team, since the code is open source .\r\n\r\nAlternatively, you might want to add the following line of code, so the timezone is converted to UTC before trying to insert the row into BigQuery. Please let me know if this workaround worked for you:\r\n```\r\nproblem_date = datetime.datetime(2017, 11, 1, 4, 8, tzinfo=tzoffset(None, -25200))\r\nproblem_date = problem_date.astimezone(datetime.timezone.utc)\r\n```\r\n\r\n[1]:\r\nhttps://github.com/googleapis/python-bigquery/releases/tag/v2.5.0\r\n[2]:\r\nhttps://github.com/googleapis/python-bigquery/pull/393\r\n[3]:\r\nhttps://github.com/googleapis/python-bigquery/issues\r\n\r\n-------------------------------\r\n\r\nWe will look into the feasibility of the workaround\r\n\r\n\r\n","author":{"url":"https://github.com/zsolt-sb","@type":"Person","name":"zsolt-sb"},"datePublished":"2021-01-19T17:18:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/476/python-bigquery/issues/476"}
| 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:74e61326-34a8-ee10-301c-32da42e7289f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8918:53234:15D70E9:1DAEFD4:6A4F2402 |
| html-safe-nonce | 409b21258ef2cdf98db3960154a7bbf3c2a387b72e43788cfc440e5ad4c4fce3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTE4OjUzMjM0OjE1RDcwRTk6MURBRUZENDo2QTRGMjQwMiIsInZpc2l0b3JfaWQiOiI4ODgzNDU5ODkwMzg5NDExODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8c365a36114d7a5e83ccd524777da675546d643e21d7ac9582c48941346afd37 |
| hovercard-subject-tag | issue:789208541 |
| 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/python-bigquery/476/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8e86a36c8ab488529e20a17a9e50c4ba44326764e6cf75bf096b64d43e883793/googleapis/python-bigquery/issues/476 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8e86a36c8ab488529e20a17a9e50c4ba44326764e6cf75bf096b64d43e883793/googleapis/python-bigquery/issues/476 |
| og:image:alt | This code works with with the python package google-cloud-bigquery==2.2.0 but it does not work with this package google-cloud-bigquery==2.6.0 What you expected to happen: I expect the client librar... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zsolt-sb |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-bigquery git https://github.com/googleapis/python-bigquery.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992475 |
| octolytics-dimension-repository_nwo | googleapis/python-bigquery |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992475 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-bigquery |
| 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 | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width