I‘m using the influxdb-php lib to read from and write to influx. I haven‘t thought much of it in the beginning and just started to import date into the db, which worked fine. But later when I added some importers, I stumbled over type conflict issues like that: write failed: field type conflict: input field "value" on measurement "temp" is type integer, already exists as type float
So it seems that the first value I inserted was interpreted as a float (even though it doesn‘t need to be one), which resulted in that type.
Now I always need type cast to float (which I forget pretty often when implementing a new importer) even though in this measurement only integer values will be added.
Additionally the query show field keys from temp returns this:
So two types for one field? It is just confusing.
The question is now: is there any way to “repair” this, so that a) there is only one type which b) is integer?
Well, the problem is that, as far as I know, with the PHP infliux library you can‘t force a datatype, but it tries to find the best matching type for the set value. The only thing around it is to really type cast before putting it into the library. And this is the whole issue I have: I forgot to do it once, and now have two different datatypes in the measurement, but even though float and integer are available the insert call throws these data type errors. So I don‘t really see where this second data type comes from, but would be fine with it if it would mean that I can add integers AND floats.
That is what I thought of in regards of fixing it. To bad, that there is no simpler way. But thanks for the tip!