GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: preserve timestamp microsecond precision with rows from REST API by HemangChothani · Pull Request #402 · googleapis/python-bigquery

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

Conversation

@HemangChothani

@HemangChothani HemangChothani commented Nov 25, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #395

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@HemangChothani
feat: add formatOption default tru for tablelist and query result
62da07e
@HemangChothani
HemangChothani requested a review from tswast November 25, 2020 15:30
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 25, 2020
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Nov 25, 2020
tswast
tswast reviewed Nov 30, 2020
View reviewed changes
Comment thread google/cloud/bigquery/_helpers.py
"""Coerce 'value' to a datetime, if set or not nullable."""
if _not_null(value, field):
# value will be a float in seconds, to microsecond precision, in UTC.
return _datetime_from_microseconds(1e6 * float(value))

@tswast tswast Nov 30, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This will need to be modified to parse from an rfc timestamp string.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@HemangChothani HemangChothani Dec 1, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Sorry, i didn't get the point. Before passing params["formatOptions.useInt64Timestamp"] = True in client.list_row, received a value in string with decimal in _timestamp_from_json method , but after passing it, received a value in string without decimal and call the method _datetime_from_microseconds(int(value)) which returns datetime object.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tswast tswast Dec 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Oh I see. Yes, that's expected.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tswast tswast Dec 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

In this case, we should update the comment.

Also, are there cases where floating point values are still passed in? If not, we should clean this up now. If so, let's add a TODO to identify those cases and file an issue to clean them up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tswast
tswast reviewed Dec 1, 2020
View reviewed changes
Comment thread google/cloud/bigquery/_helpers.py Outdated
elif value.isdigit():
value = int(value)
else:
value = 1e6 * float(value)

@tswast tswast Dec 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Why is this case needed? Couldn't the above isdigit() check be removed and we always fall back to converting to integer? I don't expect floating point values to be serialized as strings in JSON.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
HemangChothani added 2 commits December 2, 2020 20:40
@HemangChothani
feat: remove float point serialize
a3ed82b
@HemangChothani
Merge branch 'master' of https://github.com/googleapis/python-bigquery …
c7272fe
…into bigquery_issue_395
@HemangChothani
HemangChothani marked this pull request as ready for review December 2, 2020 15:11
@HemangChothani
HemangChothani requested a review from a team December 2, 2020 15:11
HemangChothani added 2 commits December 3, 2020 10:48
@HemangChothani
fix: lint
bc11fcf
@HemangChothani
Merge branch 'master' of https://github.com/googleapis/python-bigquery …
3ca9cf6
…into bigquery_issue_395
tswast
tswast reviewed Dec 3, 2020
View reviewed changes
Comment thread google/cloud/bigquery/_helpers.py Outdated
return _datetime_from_microseconds(1e6 * float(value))
# value will be a integer in seconds, to microsecond precision, in UTC.

# if value is not None:

@tswast tswast Dec 3, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please remove commented out code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
HemangChothani added 2 commits December 4, 2020 13:15
@HemangChothani
feat: remove comments
8eb90bd
@HemangChothani
Merge branch 'master' of https://github.com/googleapis/python-bigquery …
8acca69
…into bigquery_issue_395
@tswast tswast changed the title feat: add formatOption default tru for tablelist and query result fix: preserve timestamp microsecond precision with rows from REST API Dec 4, 2020
tswast
tswast approved these changes Dec 4, 2020
View reviewed changes
@tswast
tswast merged commit 04510a7 into googleapis:master Dec 4, 2020
@release-please release-please Bot mentioned this pull request Jan 4, 2022
chore(main): release python-bigquery 1.27.1 #1097
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@tswast tswast tswast approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Use DataFormatOptions to download timestamps with full precision

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@HemangChothani @tswast
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.