Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timestamps returned by the lib lose microsecond precision #494

Closed
pascaldelange opened this issue Jan 11, 2019 · 4 comments
Closed

timestamps returned by the lib lose microsecond precision #494

pascaldelange opened this issue Jan 11, 2019 · 4 comments
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@pascaldelange
Copy link

Hi,

When querying values from Spanner with the nodejs lib, all timestamps lose microsecond precision (they are truncated to milliseconds).
This makes pagination really painful on fields with commit timestamps, since truncating can create lots of cases where entries are missed/duplicate depending on the order.
Other languages (I tried python) properly keep microsecond precision.
Is this a know issue ?

  • OS: all
  • Node.js version: 10
  • @google-cloud/spanner version: 2.0
@JustinBeckwith JustinBeckwith added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 11, 2019
@JustinBeckwith
Copy link
Contributor

FYI @crwilcox

@callmehiphop
Copy link
Contributor

callmehiphop commented Jan 11, 2019

Is this a known issue ?

It is now!

JavaScript dates only keep up to millisecond precision, so it looks like we are probably going to want to create a custom wrapper for timestamps.

I imagine it'll probably resemble the SpannerDate class

class SpannerTimestamp {
  value: string; // '2019-01-11T22:13:22.620145Z'
  toDate(): Date; // not recommended if precision is needed
}

Thoughts?

/cc @stephenplusplus

@crwilcox
Copy link
Contributor

Python has a similar issue regarding precision. So all datetimes need to be handled using custom classes.

@pascaldelange
Copy link
Author

Thoughts?

This would do the job for me :)

Python has a similar issue regarding precision. So all datetimes need to be handled using custom classes.

I'm pretty sure the problem is not there in python. The sdk returns python datetime objects that have precision up to microseconds (though they are not json serializable, which is another problem)

@google-cloud-label-sync google-cloud-label-sync bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Jan 31, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants