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

[feature request] Should support ceil and floor functions #3691

Closed
pauldix opened this issue Aug 17, 2015 · 6 comments
Closed

[feature request] Should support ceil and floor functions #3691

pauldix opened this issue Aug 17, 2015 · 6 comments

Comments

@pauldix
Copy link
Member

pauldix commented Aug 17, 2015

Some users want to round results from math and aggregates. These functions should act like transformation functions (like derivative). For example say you have a series where you're reporting uptime in seconds for devices and you want to show how many days it has been up.

-- ceil rounds up, floor rounds down
-- the first argument is the thing you're taking the ceiling of
-- this would give you as many data points as you have uptime reports, many of which
-- would be the same because of the large divisor
select ceil(value / 86400) from uptime where time > now() - 30d

-- if you're reporting uptime frequently, you may want to limit the number of points here
-- this would give you only 30 data points back
select ceil(last(value) / 86400) from uptime where time > now() - 30d group by time(1d) 

-- ceil and floor should support an optional second argument that specifies the precision to round to
select ceil(value / 86400, .2f) from uptime where time > now() - 30d

Just my initial thoughts on this. Feedback welcome.

@laf
Copy link

laf commented Aug 17, 2015

Thanks @pauldix

Exactly what we're looking for :)

@beckettsean beckettsean changed the title Should support ceil and floor functions [feature request] Should support ceil and floor functions Aug 17, 2015
@beckettsean beckettsean modified the milestones: Longer term, Future Point Release Aug 25, 2015
@musl
Copy link

musl commented Dec 30, 2015

@pauldix Great idea. This will make some history graphs easier to make and read - especially for those targeted at an audience that's not expected to be well versed in statistics. I think it'll also help with clarity and style in other cases.

@toddboom
Copy link
Contributor

Also adding a request for round() in response to #5435.

@beckettsean
Copy link
Contributor

As mentioned in my post to the mailing list we are experimenting with simplifying our open GitHub Issues. This feature request has been rolled into an aggregate issue for all function requests, so that we can close this issue until we are ready to work on it.

You may continue to make comments here. Closing the issue does not mean we are rejecting this idea.

@MikiDi
Copy link

MikiDi commented Jun 12, 2017

Hi,
I would like to have a go at implementing the CEIL() and FLOOR() functions.
However, I'm new to the project ... could anyone give some pointers on what to look at first, which special cases to consider, etc? :-)

Michaël

@timhallinflux
Copy link
Contributor

closed via #9632

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

No branches or pull requests

8 participants