influxdb
influxdb copied to clipboard
Inside a subquery, time range of main query is used instead
System info: InfluxDB versions tested: 1.3.5, 1.5.3, 1.6.0 Shell version 1.7.0~n201806140800 Ubuntu 16.04 Installed influx from nightly builds.
Steps to reproduce:
- Insert this data in a database:
[
{
"measurement": "test_measurement",
"time": "2018-06-12T17:00:00Z",
"fields": {
"numeric_value": 9
}
},
{
"measurement": "test_measurement",
"time": "2018-06-13T16:20:00Z",
"fields": {
"numeric_value": 12
}
},
{
"measurement": "test_measurement",
"time": "2018-06-13T18:45:00Z",
"fields": {
"numeric_value": 10
}
}
]
- Execute this query (workaround for time-weighted average):
SELECT mean(numeric_value) as numeric_value FROM (
SELECT mean(numeric_value) AS numeric_value
FROM test_measurement
WHERE time >= '2018-06-13T00:00:00Z' - 24h AND time <= '2018-06-14T00:00:00Z'
GROUP BY time(1s) FILL(previous))
WHERE time >= '2018-06-13T00:00:00Z' - 24h AND time <= '2018-06-14T00:00:00Z'
GROUP BY time(1h) ORDER BY time ASC
Results, as expected (before the first value in the db, null is returned for each hour):
time numeric_value
---- -------------
2018-06-12T00:00:00Z
2018-06-12T01:00:00Z
2018-06-12T02:00:00Z
2018-06-12T03:00:00Z
2018-06-12T04:00:00Z
2018-06-12T05:00:00Z
2018-06-12T06:00:00Z
2018-06-12T07:00:00Z
2018-06-12T08:00:00Z
2018-06-12T09:00:00Z
2018-06-12T10:00:00Z
2018-06-12T11:00:00Z
2018-06-12T12:00:00Z
2018-06-12T13:00:00Z
2018-06-12T14:00:00Z
2018-06-12T15:00:00Z
2018-06-12T16:00:00Z
2018-06-12T17:00:00Z 9
2018-06-12T18:00:00Z 9
2018-06-12T19:00:00Z 9
2018-06-12T20:00:00Z 9
2018-06-12T21:00:00Z 9
2018-06-12T22:00:00Z 9
2018-06-12T23:00:00Z 9
2018-06-13T00:00:00Z 9
2018-06-13T01:00:00Z 9
2018-06-13T02:00:00Z 9
2018-06-13T03:00:00Z 9
2018-06-13T04:00:00Z 9
2018-06-13T05:00:00Z 9
2018-06-13T06:00:00Z 9
2018-06-13T07:00:00Z 9
2018-06-13T08:00:00Z 9
2018-06-13T09:00:00Z 9
2018-06-13T10:00:00Z 9
2018-06-13T11:00:00Z 9
2018-06-13T12:00:00Z 9
2018-06-13T13:00:00Z 9
2018-06-13T14:00:00Z 9
2018-06-13T15:00:00Z 9
2018-06-13T16:00:00Z 11
2018-06-13T17:00:00Z 12
2018-06-13T18:00:00Z 11.5
2018-06-13T19:00:00Z 10
2018-06-13T20:00:00Z 10
2018-06-13T21:00:00Z 10
2018-06-13T22:00:00Z 10
2018-06-13T23:00:00Z 10
2018-06-14T00:00:00Z 10
- Now execute this query, reducing the range of the outer query:
SELECT mean(numeric_value) as numeric_value FROM (
SELECT mean(numeric_value) AS numeric_value
FROM test_measurement
WHERE time >= '2018-06-13T00:00:00Z' - 24h AND time <= '2018-06-14T00:00:00Z'
GROUP BY time(1s) FILL(previous))
WHERE time >= '2018-06-13T00:00:00Z' AND time <= '2018-06-14T00:00:00Z'
GROUP BY time(1h) ORDER BY time ASC
Expected behavior: Only the part within the outer query range is returned, but taken from the inner query so there are no nulls:
2018-06-13T00:00:00Z 9
2018-06-13T01:00:00Z 9
2018-06-13T02:00:00Z 9
2018-06-13T03:00:00Z 9
2018-06-13T04:00:00Z 9
2018-06-13T05:00:00Z 9
2018-06-13T06:00:00Z 9
2018-06-13T07:00:00Z 9
2018-06-13T08:00:00Z 9
2018-06-13T09:00:00Z 9
2018-06-13T10:00:00Z 9
2018-06-13T11:00:00Z 9
2018-06-13T12:00:00Z 9
2018-06-13T13:00:00Z 9
2018-06-13T14:00:00Z 9
2018-06-13T15:00:00Z 9
2018-06-13T16:00:00Z 11
2018-06-13T17:00:00Z 12
2018-06-13T18:00:00Z 11.5
2018-06-13T19:00:00Z 10
2018-06-13T20:00:00Z 10
2018-06-13T21:00:00Z 10
2018-06-13T22:00:00Z 10
2018-06-13T23:00:00Z 10
2018-06-14T00:00:00Z 10
Actual behavior: The range of the outer query is used for the inner query, so we have nulls until the first value in the outer query's range.
time numeric_value
---- -------------
2018-06-13T00:00:00Z
2018-06-13T01:00:00Z
2018-06-13T02:00:00Z
2018-06-13T03:00:00Z
2018-06-13T04:00:00Z
2018-06-13T05:00:00Z
2018-06-13T06:00:00Z
2018-06-13T07:00:00Z
2018-06-13T08:00:00Z
2018-06-13T09:00:00Z
2018-06-13T10:00:00Z
2018-06-13T11:00:00Z
2018-06-13T12:00:00Z
2018-06-13T13:00:00Z
2018-06-13T14:00:00Z
2018-06-13T15:00:00Z
2018-06-13T16:00:00Z 12
2018-06-13T17:00:00Z 12
2018-06-13T18:00:00Z 11.5
2018-06-13T19:00:00Z 10
2018-06-13T20:00:00Z 10
2018-06-13T21:00:00Z 10
2018-06-13T22:00:00Z 10
2018-06-13T23:00:00Z 10
2018-06-14T00:00:00Z 10
@dlazaroi can you upgrade to the latest version and confirm you have the same behaviour?
@e-dard just tried with the latest versions (1.5.3, 1.6.0) and the result is still the same. I updated the bug description to reflect all the versions tested.
This still happens with 1.6.4
This is still an issue with 1.7.3. At least on the windows version
Still an issue in 1.7.7 on Windows.
same with 1.7.8 on linux.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.
This is still an issue, please reopen.
Any update on this? As the issue is still present in version 1.8.1
Can you please update on this issue? @dgnorton
Do you know of any workaround for this? @siddu108 @hellivan
No....@amarr1143l
Still present in 1.8.6 :(