influxdata / influxdata/influxdb
[Feature request] SELECT multiple measurements with the same field keys should accept different types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
**Proposal:**
When you select multiple measurements with the same field keys but different types, allow InfluxQL to return the fields without cast.
**Current behavior:**
When you have multiple measurements and the measurements have the same field key but the types are different, InfluxQL only allows a field to have one type and it will choose one and drop types that can't be cast to the choosen type.
Example:
```
> insert m1 value=42i
> insert m2 value=42
> insert m3 value="Answer to the Ultimate Question of Life, the Universe, and Everything"
> insert m4 value=True
> select * from /.*/
name: m1
time value
---- -----
1530106663275592500 42
name: m2
time value
---- -----
1530106670931703700 42
```
More information: #8858 & #10006
**Desired behavior:**
When you have multiple measurements and the measurements have the same field key but the types are different, InfluxQL should allow the fields to have any type.
So, if you use this query `SELECT * FROM /.*/` InfluxQL will not drop any field.
Example:
```
> insert m1 value=42i
> insert m2 value=42
> insert m3 value="Answer to the Ultimate Question of Life, the Universe, and Everything"
> insert m4 value=True
> select * from /.*/
name: m1
time value
---- -----
1530106663275592500 42
name: m2
time value
---- -----
1530106670931703700 42
name: m3
time value
---- -----
1530106663275592500 Answer to the Ultimate Question of Life, the Universe, and Everything
name: m4
time value
---- -----
1530106670931703700 True
```
**Use case:**
I think it's common to have multiple measurements with the same field key (e. g. "value") but with different types. In this case, the current behavior is a problem to:
- Restore a database that already exists: #9887
- Use Kapacitor batch tasks & CQs: #10022
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue's INSERT and SELECT examples in InfluxQL, then trace how wildcard queries reconcile same-named fields across measurements. Done means the query returns integer, float, string, and boolean values without dropping incompatible types, with coverage for the demonstrated cases.
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100