-
Notifications
You must be signed in to change notification settings - Fork 211
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
fix: BigQueryTimestamp should keep accepting floats #1339
fix: BigQueryTimestamp should keep accepting floats #1339
Conversation
As you mentioned in #1338 if you want to move away from accepting floats, you could mark this as depreciated or update the documentation for this class to mention it. I think I would've opted to work with |
But our public docs only mention the
I checking here, but I think we don't have a way to mark the I opened this PR to evaluate how would be to add |
@alvarowolfx Does it make sense to revert the previous commit and tag 7.5.1 as a fix for that, then re-implement the change and tag 8.0.0 as a breaking change? I'm not sure though what is the Google policy on tagging majors.
This does mention the usage of Given the fact it's undocumented I do understand your standpoint though. Purely technical it might be a BC, but you could also reason it's a bugfix and therefore not BC at all. If none of these are possible, maybe you can adjust the 7.5.0 release note to mention this, so it's easier for others to understand any issue they might encounter. |
@stefandoorn these would be the exact steps to turn this into a breaking change and our release tooling would bump the package to 8.0.0 automatically.
What I'm considering here is if this should be classified as a breaking change or not. Of course I ended up causing a major headache for you guys, so that alone might be a reason for it, but I wonder who else was using that internal float representation by mistake. I'll discuss this with my team today and have a final answer by EOD |
Just to add more information here, the optional |
Hmmm, then I must be mixing up some things here. I think we've been passing the numeric timestamp around always between our services, but only more recent started drafting our own BigQueryTimestamp as that looked more in line with the BQ package. |
Just to clarify @stefandoorn, the
|
@@ -640,7 +640,8 @@ export class BigQuery extends Service { | |||
break; | |||
} | |||
case 'TIMESTAMP': { | |||
value = BigQuery.timestamp(value); | |||
const pd = new PreciseDate(BigInt(value) * BigInt(1000)); | |||
value = BigQuery.timestamp(pd); |
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 is similar on how it was working before this PR: https://github.com/googleapis/nodejs-bigquery/pull/1192/files
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.
Generally looks good. Should we be clearer in the BigQueryTimestamp
documentation about what the numeric format represents? It may help users avoid problems if they do use a number value in the constructor.
Hey @shollyman 👋, as a user of this package it was a bit of a guessing game as to what the number represented, so I think that would be a great idea to update the docs to make sure thats clear. |
yes, gonna add extra docs about that. |
@yeoffrey @stefandoorn I added more comments to the timestamp related functions and also the good news is that we are bringing back the parsing functionality of the BigQueryTimestamp class and still making it work with the newer changes for better and more precise int64 timestamps. So this will be a fix to the previous breaking change and will keep it backward compatible. |
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.
Thanks for this. As a followup, consider adding a blurb to CHANGELOG.md in the release-please PR to call out the potential issue with parsing in the previous version(s).
Thanks @alvarowolfx - appreciate the quick handling of this! :) |
Thank you very much! |
Add back parsing of timestamps as floats, as some users where relying on that internal format.
A example of that is passing
Date.now()/1000)
. This worked in the past because internally the library was parsing BigQuery timestamps being returned as a float representation from the service side. We moved away from it due to it being imprecise and now theformatOptions.useInt64Timestamp
is available, which makes the timestamps to be return as a int64 in usec.This PR restores the BigQueryTimestamp parsing and converts the int64 timestamp coming from the service side before passing to the BigQueryTimestamp constructor, so the class don't need to handle microsecond parsing for now and we keep it backward compatible.
Fixes #1338 🦕
BEGIN_COMMIT_OVERRIDE
fix: BigQueryTimestamp should keep accepting floats #1339
fix: restores BigQueryTimestamp behavior to accept a numeric value in the constructor representing epoch-seconds. The affected 7.5.0 version would parse a numeric value as epoch-microseconds.
fix: add better documentation around usage of BigQueryTimestamp class and .timestamp method.
END_COMMIT_OVERRIDE