Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

fix: timestamp precision in insert_rows - #393

Merged
tswast merged 3 commits into
googleapis:masterfrom
MaxxleLLC:bigquery_issue_392
Nov 23, 2020
Merged

fix: timestamp precision in insert_rows#393
tswast merged 3 commits into
googleapis:masterfrom
MaxxleLLC:bigquery_issue_392

Conversation

@HemangChothani

Copy link
Copy Markdown
Contributor

Fixes#392

@HemangChothani
HemangChothani requested review from a team and tswastNovember 19, 2020 07:51
@google-clagoogle-claBot added the cla: yes This human has signed the Contributor License Agreement. label Nov 19, 2020
@product-auto-labelproduct-auto-labelBot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Nov 19, 2020

@tswasttswast left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a system test for this. It'll need to query the table that rows are inserted into in order to ensure the values roundtrip correctly.

Comment threadgoogle/cloud/bigquery/_helpers.py Outdated
@tswast

Copy link
Copy Markdown
Contributor

As my explorations showed in #392 (comment), we can format the date using YYYY-MM-DDTHH:MM:SS.MMMMMMZ instead of doing any sort of conversion to floating point.

Comment threadtests/unit/test__helpers.py Outdated

when = datetime.datetime(2016, 12, 20, 15, 58, 27, 339328)
self.assertEqual(self._call_fut(when), _microseconds_from_datetime(when) / 1e6)
self.assertEqual(self._call_fut(when), when.strftime(_RFC3339_MICROS))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please update these tests to compare against the actual string produced. I trust that when.strftime(_RFC3339_MICROS) is doing the right thing, but I'd be much more comfortable seeing the actual formatted string here and in the other unit tests.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timestamp loss of precision in insert_rows

2 participants

@HemangChothani@tswast