influxdata / influxdata/influxdb
Time-filter of Sub-Query ignored (1.*)
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
If you use subqueries, whilst each query has it's own time filter the computing is very unintuitive or simply wrongful.
__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.
1. `SELECT sum(*) FROM(SELECT non_negative_difference("errorCount") as count FROM "programm_metrics" WHERE ("daily" = 'True') AND time >= 14d) WHERE time >= now()-1d`
Since differences require at least two datapoints, I'm requesting first a bigger timespan within the inner query. This should result in a list of about 14-28 datapoints, each having a positive value.\
Then I want to get my last value / sum of the values within the last 24h.\
I do not want to use the grouping clause, since that cuts out any errors within the grouping duration - I want to know ASAP if there is a new error change.
The same can be experienced on grouping clauses with different time ranges.
__Expected behavior:__
One Datapoint, having the last change in errors(0+).
Using first the 14-day data of the inner query, computing the result.\
Afterwards using the outer query to only return the sum of the values within the last 24h
__Actual behavior:__
No Datapoint since the outer time-filter is also applied onto the inner query. A difference always needs at least two points.
Probably a harmful optimization. \
It already reduces the time from the inner query onto a maximum of 1d, instead of 14d. \
Therefore data and sums are missing.
__Environment info:__
* System info: Linux 4.18.0-240.22.1.el8_3.x86_64 x86_64
* InfluxDB version: InfluxDB v1.8.4 (git: 1.8 bc8ec4384eed25436d31045f974bf39f3310fa3c)
* Other relevant environment details: --
__Config:__
Auth HTTPS enabled using self-signed cert
Flux enabled but unused
Contributor guide
Research direction
No source files or tests are named. Start by reproducing the InfluxQL query against InfluxDB 1.8.4 and tracing how the outer and inner time filters are applied to the sub-query. Done means the inner query can use its 14-day range before the outer query restricts results to the last 24 hours, with the expected datapoint returned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100