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

Type conversion exception #791

Open
LMH269084857 opened this issue Dec 2, 2021 · 13 comments
Open

Type conversion exception #791

LMH269084857 opened this issue Dec 2, 2021 · 13 comments

Comments

@LMH269084857
Copy link

A field is an Integer in the database, but it is a Double value when it is retrieved

@UglyHobbitFeet
Copy link

UglyHobbitFeet commented Jan 25, 2022

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

@UglyHobbitFeet
Copy link

UglyHobbitFeet commented Jan 25, 2022

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

@LMH269084857
Copy link
Author

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

@UglyHobbitFeet
Copy link

UglyHobbitFeet commented Mar 15, 2022

@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!

@majst01
Copy link
Collaborator

majst01 commented Mar 15, 2022

If someone is willing to look deeper into the the root cause of this i will review any PR.

@UglyHobbitFeet
Copy link

@majst01 I already did. It's mentioned on this thread a few comments up :)

@majst01
Copy link
Collaborator

majst01 commented Mar 15, 2022

Sure, this is the why, but whats the solution ?

@UglyHobbitFeet
Copy link

@majst01 To change "value = ((Integer) value).doubleValue()"; to "value = ((Integer) value)";

@majst01
Copy link
Collaborator

majst01 commented Mar 15, 2022

@majst01 To change "value = ((Integer) value).doubleValue()"; to "value = ((Integer) value)";

Fine, write a PR and make all unit tests pass again

@UglyHobbitFeet
Copy link

@majst01 Unfortunately I don't know how to do that. I'm not a big githubber sorry

@majst01
Copy link
Collaborator

majst01 commented Mar 15, 2022

@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/

@UglyHobbitFeet
Copy link

UglyHobbitFeet commented Mar 15, 2022

@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

@UglyHobbitFeet
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants