Filed type error


Using InfluxDB 2.7.1

I have a question about field types inside the influxdb shards and how they defined.

So I write to the database using the python API by using the line protocol, for example, Measurement name “DevicePower” and signal name “Power_Out”, this is a On-Off signal (so should be either bool or integer)

I write it like this:

A: “DevicePower Power_Out=1 1703235514605”

B: “DevicePower Power_Out=1 1703663691558”

I encountered instances when my script reports an error when writing to the InfluxDB, the error is of conflicting field type:

“failure writing points to database: partial write: field type conflict: input field "Power_Out" on measurement "DevicePower" is type float, already exists as type integer”

sometimes its the other way around: “is type integer, already exists as type float”

I thought the type is decided using the value itself (1 for integer, 1.0 for float)

So I wanted to check what is the type of Power_Out in the datebase, and I decided to use the following query:

import “types”

from (bucket: “devices”)

|>range start: v.timeRangeStart, stop: v.timeRangeStop)

|> filter(fn: (r) => r._field == “Power_Out”)

|> aggregateWindow(every: 1m, fn: last, createEmpty: false)

|> filter(fn: (r) => types.isType(v: r._value, type: “float”))


changing also the float to integer/uint - in all of the cases this query returns data only when the type is float, even when the values that I pass are 100% integers/ unsigned integers.

So how is the type decided and how can I influence it or control it?

Have a great 2024,