influxdata / influxdata/influxdb
Influx 2: schema.measurementFieldKeys does always return type string
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__Steps to reproduce:__
I am trying to check the type of data stored for a measurement in the __value_ field. The idea is to recognize e.g. if measurements are stored as boolean-value, so in a subsequent query I can avoid running flux-functions that do not support that datatype as input.
Reading through the documentation, it sounds like looking at field-keys is the way to identify the type of __value_, but I see weird results:
```
influx query 'from(bucket: "iobroker") |> range(start: 1999-12-31T23:00:00.000Z, stop: 2021-07-24T11:48:54.968Z) |> filter(fn: (r) => r["_measurement"] == "0_userdata.0.example_state")'
Result: _result
Table: keys: [_start, _stop, _field, _measurement, ack, from, q]
_start:time _stop:time _field:string _measurement:string ack:string from:string q:string _value:bool _time:time
------------------------------ ------------------------------ ---------------------- -------------------------- ---------------------- ---------------------- ---------------------- ------------ ------------------------------
1999-12-31T23:00:00.000000000Z 2021-07-24T11:48:54.968000000Z value 0_userdata.0.example_state false system.adapter.admin.0 0 false 2021-07-24T08:47:43.312000000Z
```
This tells me, that data of type boolean is stored as part of the measurement (_value:bool).
However looking at the field keys for the measurement returns a different result:
```
influx query 'import "influxdata/influxdb/schema" schema.measurementFieldKeys(bucket: "iobroker", measurement: "0_userdata.0.example_state")'
Result: _result
Table: keys: []
_value:string
----------------------
value
```
I'd expect something like __value:bool_ here, right?
Is this a bug, or am I misunderstanding something here? How could I check which datatype is used for points stored within a measurement?
__Environment info:__
* System info: Linux 4.4.0-19041-Microsoft x86_64 (WSL, Ubuntu)
* InfluxDB version: InfluxDB 2.0.7 (git: 2a45f0c037) build_date: 2021-06-04T19:17:40Z
Contributor guide
Research direction
Start by reproducing the reported measurement query and schema.measurementFieldKeys call against the stated InfluxDB 2.0.7 environment. Trace the field-key behavior and compare its result with the observed _value:bool output. Done means establishing whether the type mismatch is intended, then correcting the behavior or documenting how to inspect point types.
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100