-
Notifications
You must be signed in to change notification settings - Fork 478
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
Rounding error when reading long from db and then writing it back. #440
Comments
@kirillsc just fyi: not completely related with your issue but InfluxDB supports cast operations[1] on float->integer and integer->float since v1.0. [1] https://docs.influxdata.com/influxdb/v1.5/query_language/data_exploration/#cast-operations |
@kirillsc unfortunately I don't think there is an easy way to fix your issue and be backward compatible. The current JSON parser[1] used by influxdb-java is not "smart" enough to handle non-floating[2] point numbers as integer or long (or even BigInteger as Jackson does). |
Thank you for the clarification and the links! |
Accordingly[1] with a Moshi developer, with the next (unreleased) version we may have our own custom JsonAdapter for numbers. |
Any update on this bug? |
1 similar comment
Any update on this bug? |
moshi 1.6 is released with this feature @fmachado do you know exactly what to do ? |
I create a branch which sets dependency to moshi 1.8.0, any ideas howto implement this explicit cast welcome |
Quick update on this issue: I manage to fix this and I will commit my changes later today so you can review @majst01 |
tl;dr: if you are using InfluxDB 1.4+, use the @majst01 I pushed some code to your branch so we can all discuss here about 5f5b9ea Points for consideration:
|
Hi,
I am observing rounding errors on integer fields when reading from database and writing them back.
I have a measurement with an integer column that represents a timestamps with nanosecond resolution (note, this is not the default time column).
I am reading the data from database using influxdb-java. All integer values that I am reading are Doubles now (this I believe related to this issue).
For completeness, before writing values back to db, I am adding one more column where I take original value of the "ts_egr" column and convert it to Long before writing it back, i.e.,:
Now I am reading a row from the original table and the new table in InfluxDB:
Note, the original value of "ts_ingr" 1523264395509072018 has been changed to 1523264395509072100 (just by reading and writing it back) and if we do conversion back to Long in Java we get another variant 1523264395509072128. Overall, I was observing rounding errors up to 100 nanoseconds.
Am I doing something wrong here, and is there a way to avoid the rounding errors?
Thank you
The text was updated successfully, but these errors were encountered: