Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to perform math on derivative #5571

Closed
jessetan opened this issue Feb 8, 2016 · 2 comments · Fixed by #5643
Closed

Unable to perform math on derivative #5571

jessetan opened this issue Feb 8, 2016 · 2 comments · Fixed by #5643

Comments

@jessetan
Copy link

jessetan commented Feb 8, 2016

This works:

> SELECT derivative(last(value)) FROM "processes_user" WHERE time > now() - 2m GROUP BY time(10s) fill(0)
name: processes_user
--------------------
time            derivative
1454927430000000000 30000
1454927440000000000 30000
1454927450000000000 30000
1454927460000000000 20000
1454927470000000000 40000
1454927480000000000 30000
1454927490000000000 20000
1454927500000000000 30000
1454927510000000000 30000
1454927520000000000 30000
1454927530000000000 -1.41353e+09
1454927540000000000 3.2173e+09

This does not work:

> SELECT derivative(last(value)) / 10  FROM "processes_user" WHERE time > now() - 2m GROUP BY time(10s) fill(0)
name: processes_user
--------------------
time
1454927440000000000 0
1454927450000000000 0
1454927460000000000 0
1454927470000000000 0
1454927480000000000 0
1454927490000000000 0
1454927500000000000 0
1454927510000000000 0
1454927520000000000 0
1454927530000000000 0
1454927540000000000 0
1454927550000000000 0

Seems similar to #4849
Observed on InfluxDB 0.9.6.1 running on Centos 7.2.

@jwilder
Copy link
Contributor

jwilder commented Feb 10, 2016

This should be working now that #5196 is merged.

select derivative(value) * 10 from cpu where host='server-1' and time > '2006-01-01'

seems to work, but derivative w/ an aggregate seems to have regressed so math does not work:

select derivative(sum(value), 1s) from cpu where host='server-1' and time > '2006-01-01' group by time(1h)

@jsternberg jsternberg self-assigned this Feb 11, 2016
@jsternberg
Copy link
Contributor

I'm able to get this working, although more work is still needed on getting the fill iterator in the correct place.

> select mean(value) from cpu where time >= 1455204070s and time < 1455204090s group by time(10s)
name: cpu
---------
time                    mean
1455204070000000000     1
1455204080000000000     2

> select derivative(mean(value), 1s) from cpu where time >= 1455204070s and time < 1455204090s group by time(10s)
name: cpu
---------
time                    derivative
1455204080000000000     0.1

> select derivative(mean(value), 1s) * 10 from cpu where time >= 1455204070s and time < 1455204090s group by time(10s)
name: cpu
---------
time
1455204080000000000     1

This was tested based on two points in two adjacent intervals off of 8d7a4a9.

jsternberg added a commit that referenced this issue Feb 11, 2016
Derivatives rely on the underlying iterator to handle start and end
times. They do not perform them or organize points into groups. In
certain circumstances, the start time or end time that got implicitly
passed could be on an uneven interval with the first point returned by
the aggregate, which caused the entire iterator not to be read.

This fixes #5571.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants