Fields can only store one type of data, but the same field can store different types if they are in different shards, which is probably what’s happening here.
SHOW FIELD KEYS will combine results across all the shards in your database.
Shards are an underlying feature of the storage engine, a collection of points grouped by time; you can read a bit more about them in this recent blog post by @mschae16: https://www.influxdata.com/blog/influxdb-shards-retention-policies/
One way to verify that you have different data types in the same field for different shards would be to query for the relevant field, and then scope the query by the shard’s time boundaries. You can get more information about the shards in your database by running the influx_inspect tool, as follows:
$ influx_inspect /var/lib/influxdb/data/test1
DB RP Shard File Series New (est) Min Time Max Time Load Time
test1 autogen 17 000000001-000000001.tsm 1 1 2018-06-27T09:45:03.0778939Z 2018-06-27T09:45:48.2808061Z 91.447µs
test1 autogen 17 000000002-000000001.tsm 1 1 2018-06-27T10:34:47.2318877Z 2018-06-27T10:34:47.2318877Z 49.393µs
Time Range: 2018-06-27T09:45:03.0778939Z - 2018-06-27T10:34:47.2318877Z
- test1 (est): 2 (100%)
Total (est): 2
Completed in 1.272286ms
In this example I’m generating a report from the
test1 database, which has one shards and two TSM files. You could then use the Min and Max times to scope your queries using the WHERE clause and a timestamp.
In order to avoid this in the future it probably makes sense to be more strict about the data you are inserting. Make sure that you only insert data of type
float into that field in the database, for example.