I am using influxdb V2.X and I am saving points with different tags, but the same field name. All points in _value do not have the same data type, and I get this error, how can I fix it? I want to use the same field name…
Reason: Unprocessable entity
HTTP response headers: <CIMultiDictProxy(‘Content-Type’: ‘application/json; charset=utf-8’, ‘X-Influxdb-Build’: ‘OSS’, ‘X-Influxdb-Version’: ‘v2.7.6’, ‘X-Platform-Error-Code’: ‘unprocessable entity’, ‘Date’: ‘Wed, 07 Aug 2024 10:26:45 GMT’, ‘Content-Length’: ‘221’)>
HTTP response body: b’{“code”: “unprocessable entity”, “message”: “failure writing points to database: partial write: field type conflict: input field “P_out” in measurement “RealTime” is of type float, already exists as type integer dropped=1”}‘’.
@javierquinttana There isn’t really a way to fix this, but there are ways to work around it moving forward. Fields should never change type and if these should be treated as two separate fields, they should be written as two separate fields. While it’s possible that they can if the two types are stored in different shards, but this is an edge case.
To move forward, you have the following options:
Create new fields with the type you want to use and ensure the write mechanism is writing to each field correctly.
If you want to change the type of data currently stored, you’ll have to migrate the existing data to a new measurement and cast the field to the desired type. This can be a lot of work and I would generally shy away from this.
From the sounds of it, it sounds like a schema issue. If you have multiple sources writing the same field key, the field values should always be the same type. If the types are supposed to be different, then you need to write to two distinct fields.