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 conflict on insert int value in float field #3460

Closed
vmire opened this issue Jul 24, 2015 · 11 comments
Closed

Type conflict on insert int value in float field #3460

vmire opened this issue Jul 24, 2015 · 11 comments

Comments

@vmire
Copy link

vmire commented Jul 24, 2015

Sometimes, float measurements are integers (no decimals)

HTTP INSERT POST BODY :

node13 B6A2021050000=25,BE6B820050000=24.6

results in an error :

write failed: field type conflict: input field "B6A2021050000" on measurement "node13" is type int64, already exists as type float

And if it's the first insert : field type is wrongly defined as integer
Following inserts errors :

write failed: field type conflict: input field "BE6B820050000" on measurement "node13" is type float64, already exists as type integer

InfluxDB version : 0.9.1

@beckettsean
Copy link
Contributor

This is known and documented behavior, not a bug. The first point written to a series (on a given shard) determines the data type of the field(s).

The way to avoid it is to write all floats with a decimal, so rather than B6A2021050000=25 you write B6A2021050000=25.0, which parses as a float and will work.

Because of this and a host of other issues, we're considering ditching int64 as a user data type entirely and just making every number in the system (other than timestamps) a float64. There should be an explicit decision one way or the other with 0.9.3 in mid-August.

@beckettsean
Copy link
Contributor

See "Fields" on https://influxdb.com/docs/v0.9/write_protocols/line.html for the documentation

@tanji
Copy link

tanji commented Nov 20, 2015

What concerns me with this behavior, notably with telegraf, is that it causes the whole batch insert to fail, not only the data which conflicts:
2015/11/20 16:31:25 Error in output [influxdb-0]: Could not write to any InfluxDB server in cluster, retrying in 12.713705331s

@andyxning
Copy link

@beckettsean int and float has no difference. So, i think we can make it coherent to float. This also eases the situation above.

@gunnaraasen
Copy link
Member

@andyxning The information in this issue is out of date. Integers can be written to line protocol by specifying an i after the number while any field value without an i is considered a float.

https://docs.influxdata.com/influxdb/v0.13/troubleshooting/frequently_encountered_issues/#writing-integers

@abrkn
Copy link

abrkn commented Oct 6, 2016

What about the JSON protocol, @gunnaraasen?

@beckettsean
Copy link
Contributor

@abrkn The JSON write protocol was deprecated with version 0.9.1, disabled in InfluxDB 0.11, and removed in version 0.12: https://docs.influxdata.com/influxdb/v0.12/write_protocols/json/

lesinigo added a commit to lesinigo/sdm2influx that referenced this issue Jun 14, 2018
this avoids "field type conflict" errors from InfluxDB,
see influxdata/influxdb#3460 for an example
@Sevelantis
Copy link

Sevelantis commented Sep 16, 2021

Given an error:

influxdb.exceptions.InfluxDBClientError: 400: {"error":"field type conflict: input field \"value\" on measurement \"/GAS\" is type float, already exists as type integer dropped=1"}

Once you push the first Integer value to the database, then you couldn't simply 'switch' to sending floats.
What fixed the issue for me?
Drop database, then create new one (you lose all your previous data!). Now floats are being sent nicely with no exceptions.

Maybe altering column somehow from 'int' to 'float' would do, so you prevent data loss.

happy coding:)))

@Kylmakalle
Copy link

You can't even rewrite this series, because since now it's only integer series.

Why the hell i'm still on Influx...

@default-student
Copy link

This is not solved!
Influx does not allow the deletion of a measurement, field or tag. Only a complete bucket.
If a series is mistakenly initalizied or started with the wrong type, it will not be possible to change or correct!
Only Solution is to change the name of the field, to try and delete the measurement "influx delete --bucket example --start 1970-01-01T00:00:00Z --stop $(date --utc +"%Y-%m-%dT%H:%M:%SZ") --predicate '_measurement="example-measure"'
" or hope for updates.
#6150
#3460

@default-student
Copy link

it is also a good idea to enforce data types by using the

 [[processors.converter]]
  [processors.converter.fields]
    float = [

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

9 participants