influxdata / influxdata/influxdb

Integral aggregation returns wrong values

Open
#19,522 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/flux kind/bug
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.

1. Launch an instance of influx 1.8.2
2. Insert a simple series with ones only like

| Time | Value |
| -------------------- | ----- |
| 2000-01-01T00:00:00Z | 1 |
| 2000-01-01T00:00:01Z | 1 |
| 2000-01-01T00:00:02Z | 1 |
| 2000-01-01T00:00:03Z | 1 |
| 2000-01-01T00:00:04Z | 1 |
| 2000-01-01T00:00:05Z | 1 |
| 2000-01-01T00:00:06Z | 1 |
| 2000-01-01T00:00:07Z | 1 |
| 2000-01-01T00:00:08Z | 1 |
| 2000-01-01T00:00:09Z | 1 |
| 2000-01-01T00:00:10Z | 1 |

3. Run a query to get a windowed integral

```
dataset
|> aggregateWindow(
every: 5s,
fn: integral
)
|> yield()
```

__Expected behavior:__

As the ingested data only consists of ones, we'd expect to see two values returned with the integral being the length of the window.

| Start Time | End Time | Integral |
| -------------------- | -------------------- | -------- |
| 2000-01-01T00:00:00Z | 2000-01-01T00:00:05Z | 5 |
| 2000-01-01T00:00:05Z | 2000-01-01T00:00:10Z | 5 |

__Actual behavior:__

The actually returned integrals are smaller

| Start Time | End Time | Integral |
| -------------------- | -------------------- | -------- |
| 2000-01-01T00:00:00Z | 2000-01-01T00:00:05Z | 4 |
| 2000-01-01T00:00:05Z | 2000-01-01T00:00:10Z | 4 |

It looks like the last value of each "bucket" is not considered.

__Environment info:__

* System info: Docker
* InfluxDB version: 1.8.2

__Config:__

Default, only set `flux-enabled = true` for the flux query to work

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the aggregateWindow query using integral on the listed series and compare the returned bucket values with the expected 5-second integrals. Start from the Flux aggregateWindow/integral query path; done means each bucket includes its full window and returns 5 rather than 4.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.