influxdb-java
influxdb-java copied to clipboard
Type conversion exception
A field is an Integer in the database, but it is a Double value when it is retrieved
YES!, this is happening to me as well. I have the latest version installed (2.22)
When I use chronograf and look at the data it is indeed of type integer but has a value of decimal, which means it's being written to the db that way (instead of converted afterwards during a query)
FWIW I'm creating the record using line protocol:
this.influxDb.write(myInfluxDbName, null, ConsistencyLevel.ANY, myLineProtocolData);
I am also dynamically creating this on the fly via the line of code shown above. In other words, I did not create the measurement on startup/creation before running the above line of code.
As a temp workaround I am casting the result from double to int, but I shouldnt have to be doing that
Not sure if this is the reason, but it looks like it might be why (Line 157) https://github.com/influxdata/influxdb-java/blob/master/src/main/java/org/influxdb/dto/Point.java#L157
Not sure if this is the reason, but it looks like it might be why (Line 157) https://github.com/influxdata/influxdb-java/blob/master/src/main/java/org/influxdb/dto/Point.java#L157
Yes, I've tried other types of integer data. It does convert all integer data to double
@majst01 We appreciate your hard work with this package but this has been a major blocker for a while now! Will you be able to fix this in your next release and if so, do you have a rough estimate of when that will be? Thanks!
If someone is willing to look deeper into the the root cause of this i will review any PR.
@majst01 I already did. It's mentioned on this thread a few comments up :)
Sure, this is the why, but whats the solution ?
@majst01 To change "value = ((Integer) value).doubleValue()"; to "value = ((Integer) value)";
@majst01 To change "value = ((Integer) value).doubleValue()"; to "value = ((Integer) value)";
Fine, write a PR and make all unit tests pass again
@majst01 Unfortunately I don't know how to do that. I'm not a big githubber sorry
@majst01 Unfortunately I don't know how to do that. I'm not a big githubber sorry
https://jarv.is/notes/how-to-pull-request-fork-github/
@majst Thanks for that link. How do I 'make sure all unit tests pass again'
this is a maven project, an with the given shell script compile-and-tst.sh the whole project is compiled and all unit and integration tests are executed. as Described here https://github.com/influxdata/influxdb-java#contribute
@majst01 I appreciate the links. I tried but unfortunately I shouldn't be the one doing PR as I'm not familiar enough with the overall codebase and the impact of changing existing test cases. I may end up messing a useful test case to 'fit' my fix. I know what the problem is and have pointed to the line of code that is causing it... that's the best I can do.