influxdata / influxdata/influxdb
`GROUP BY time(x)` includes partial intervals
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
### Bug report
__System info:__ InfluxDB version 1.2.1
__Steps to reproduce:__
1. Insert data with an interval of 1m, but start 30s after a full minute
Example: Insert data at `00:00:30`, `00:01:30`, `00:02:30`, …
2. `SELECT mean(value) FROM data WHERE time <= now() GROUP BY time(1m)`
__Expected behavior:__
I would expect InfluxDB to only group time ranges that fully fit the into the queried time range (in this case, time ranges that have already passed)
Example:
- The last time covered by the query (`now()`) is `00:01:01`
- The last query result covers the range `00:00:00 - 00:01:00`
- _(I'm unsure if the `time` field of the result should be `00:00:00` or `00:01:00`)_
__Actual behavior:__
InfluxDB groups time ranges *extending* the queried time, in this example meaning as soon as `00:01:00` passes, it will group `00:01:00 - 00:02:00`. With data only being inserted at `00:01:30`, the last result will be `null` (until `00:01:30` passes), although data is inserted with the same interval as used in the query.
__Additional info:__
Related issues: #3926 #4282 #4038 #8010
Contributor guide
Research direction
Start by reproducing the query from the issue using the stated one-minute interval and 30-second offset. Review related issues #3926, #4282, #4038, and #8010 for the intended interval-boundary behavior, then verify that the final result excludes incomplete ranges and that its timestamp is defined.
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
- Mostly clear
- Newbie friendliness
- 35/100