influxdata / influxdata/influxdb
Influx 1.8.5 - Subqueries are broken if used on an integer field
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__Steps to reproduce:__
1. Insert those data in influxDB:
```
bug_integer,uuid=1 value=1i 1619437701000000000
bug_integer,uuid=1 value=0i 1619437760000000000
bug_integer,uuid=1 value=1i 1619437821000000000
bug_integer,uuid=2 value=1i 1619437731000000000
bug_integer,uuid=2 value=0i 1619437790000000000
bug_integer,uuid=2 value=1i 1619437851000000000
bug_float,uuid=1 value=1 1619437701000000000
bug_float,uuid=1 value=0 1619437760000000000
bug_float,uuid=1 value=1 1619437821000000000
bug_float,uuid=2 value=1 1619437731000000000
bug_float,uuid=2 value=0 1619437790000000000
bug_float,uuid=2 value=1 1619437851000000000
```
2. Run the following query on bug_float: (everything works well)
```
SELECT first("valA") as valA, first("valB") as valB, (first("valA") * first("valB")) as res
FROM
(SELECT first("value") as valA FROM "bug_float" WHERE ("uuid" = '2') AND time > 1619437700000000000 AND time < 1619437851000000000 GROUP BY time(1s) fill(previous)),
(SELECT first("value") as valB FROM "bug_float" WHERE ("uuid" = '1') AND time > 1619437700000000000 AND time < 1619437851000000000 GROUP BY time(1s) fill(previous))
WHERE time > 1619437700000000000 AND time < 1619437851000000000 GROUP BY time(1s) fill(previous)
```
```
...
[
"2021-04-26T11:50:42Z",
0,
1,
0
],
...
```
3. Run the exact same query on measurement bug_integer, (**problem: valB is always null**)
```
SELECT first("valA") as valA, first("valB") as valB, (first("valA") * first("valB")) as res
FROM
(SELECT first("value") as valA FROM "bug_integer" WHERE ("uuid" = '2') AND time > 1619437700000000000 AND time < 1619437851000000000 GROUP BY time(1s) fill(previous)),
(SELECT first("value") as valB FROM "bug_integer" WHERE ("uuid" = '1') AND time > 1619437700000000000 AND time < 1619437851000000000 GROUP BY time(1s) fill(previous))
WHERE time > 1619437700000000000 AND time < 1619437851000000000 GROUP BY time(1s) fill(previous)
```
```
...
[
"2021-04-26T11:50:42Z",
0,
null,
null
],
...
```
__Expected behavior:__
```
[
"2021-04-26T11:50:42Z",
0,
1,
0
],
```
__Actual behavior:__
```
[
"2021-04-26T11:50:42Z",
0,
null,
null
],
```
__Environment info:__
* System info: Linux 5.11.0-16-generic x86_64
* InfluxDB version: InfluxDB v1.8.5 (git: 1.8 3d16c6318cf5)
* Other relevant environment details: docker image (tag 1.8.5)
__Config:__
Default config of the official docker image (tag 1.8.5)
Contributor guide
Research direction
No source file, test, or entry point is named. Start by reproducing the two subquery cases on InfluxDB 1.8.5, comparing integer and float fields and checking the expected versus actual grouped results. Done means the integer-field query returns valB and res rather than null, with regression coverage for the reported case.
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
- Clearly specified
- Newbie friendliness
- 42/100