-
Notifications
You must be signed in to change notification settings - Fork 118
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
BigQuery: FieldValue.getTimestamp() use of Double causes precision loss in some cases. #16
Comments
Sorry, but it's not a question, it's a bug... |
退订 |
This is a bug that necessitates changes in the API backend. There's work in progress to address this. |
I think it's much simpler than that: in FieldValue.getTimestamp() replace |
Added the "blocked" label until the backend changes @shollyman referenced are known. |
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: - [X] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-bigquery/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [X] Ensure the tests and linter pass - [X] Code coverage does not decrease (if any source code was changed) - [X] Appropriate docs were updated (if necessary) Fixes #16
Environment details
General, Core, and Other are also allowed as types
Steps to reproduce
Create a row with this timestamp: 1337-09-02 11:43:21.622894 UTC, query and use fieldValue.getTimestamp(). Microseconds wouldn't be equal.
Code example
@test
public void testFloatingPointPrecisionLoss() {
FieldValue fieldValue = FieldValue.of(Attribute.PRIMITIVE, "-1.9954383398377106E10");
long received = fieldValue.getTimestampValue();
long expected = -19954383398377106L;
assertEquals(expected, received);
}
Any additional information below
Cause - floating point conversation causes it; need to use BigDecimal (or equivalent) to perform lossless conversion.
The text was updated successfully, but these errors were encountered: