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 — [BigQuery] FieldValue.getTimestampValue returns incorrect microseconds · Issue #3356 · googleapis/google-cloud-java

[BigQuery] FieldValue.getTimestampValue returns incorrect microseconds #3356

New issue
Copy link
New issue
Copy link
Closed
Closed
[BigQuery] FieldValue.getTimestampValue returns incorrect microseconds#3356
Copy link
Assignees
sduskis
Labels
api: bigqueryIssues related to the BigQuery API.type: questionRequest for information or clarification. Not an issue.

Description

@martinstuder
martinstuder
opened on Jun 7, 2018
Issue body actions

I have a BigQuery table with a timestamp column where some values are '9999-12-31 23:59:59.999 UTC' (no microseconds; i.e. TIMESTAMP_TO_USEC of that timestamp gives 253402300799999000). Retrieving such a timestamp using the Java BigQuery API (via FieldValue.getTimestampValue) results in 253402300799999008 being returned, i.e. with an additional 8 microseconds. I haven't seen this for other timestamp values yet.

Activity

  1. shollyman commented on Jun 7, 2018

    @shollyman
    shollyman
    on Jun 7, 2018
    Contributor
    More actions

    I suspect this may be related to how the BigQuery API represents TIMESTAMP values in the json API response for tabledata.list / jobs.getqueryresults, which is seconds since epoch in a potentially lossy floating point representation.

    If the goal is having microsecond precision, its likely better to project the data as microseconds (integer) rather than timestamp.

    In my quick testing, wire response is consistently 2.53402300799999E11 regardless of the sql dialect I use, but there may be some lossiness converting that in the library, as it returns timestamps to callers via conversion to usec:

    return new Double(Double.valueOf(getStringValue()) * MICROSECONDS).longValue();

  2. yihanzhen
    added
    type: questionRequest for information or clarification. Not an issue.
    api: bigqueryIssues related to the BigQuery API.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Jun 7, 2018
  3. martinstuder commented on Jun 10, 2018

    @martinstuder
    martinstuder
    on Jun 10, 2018
    Author
    More actions

    Ok, that does explain what's going on. It seems odd to me though to serialize a TIMESTAMP that way. Is there any particular reason for not serializing the usec directly and doing Long.valueOf(getStringValue()).longValue()?

  4. shollyman commented on Jun 11, 2018

    @shollyman
    shollyman
    on Jun 11, 2018
    Contributor
    More actions

    This does seem an odd representation in hindsight, which comes from BigQuery's initial public release period back in 2012 when this was a more common way of representing timestamps in web APIs. Its remained in this form to maintain compatibility for existing callers, as we'd want to change something like this with a major API revision, which hasn't occurred since that period.

  5. JustinBeckwith
    assigned
    JesseLovelace
    on Oct 17, 2018
  6. JustinBeckwith
    added
    🚨 criticalP0 critical issue. Requires immediate fix
    on Dec 4, 2018
  7. sduskis
    removed
    🚨 criticalP0 critical issue. Requires immediate fix
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Feb 5, 2019
  8. JesseLovelace
    removed their assignment
    on Mar 14, 2019
  9. sduskis commented on Apr 9, 2019

    @sduskis
    sduskis
    on Apr 9, 2019
    Contributor
    More actions

    @shollyman, is there anything we can do with this issue on the client side? If not, let's please close this issue.

  10. sduskis
    closed this as completedon May 3, 2019
  11. JustinBeckwith
    assigned
    sduskis
    on Feb 1, 2021
  12. suztomo
    added a commit that references this issue on Mar 9, 2026

    feat: add columnNameCharacterMap to LoadJobConfiguration (#3356)

    2f3cbe3
  13. chingor13
    added 4 commits that reference this issue on Mar 24, 2026

    docs: fix list num (#3356)

    dbbd049

    chore(main): release 2.50.0 (#3327)

    97dfec7

    deps: update dependency ubuntu to v24 (#3356)

    e5ed850

    chore: mpu client preview merge train

    d0ebfd9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sduskis
    sduskis

Labels

api: bigqueryIssues related to the BigQuery API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.