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

PERCENTILE(value,0) does not work, returns null instead of MIN value #4418

Closed
hughescr opened this issue Oct 12, 2015 · 6 comments

Comments

Projects
None yet
4 participants
@hughescr
Copy link

commented Oct 12, 2015

percentile(value,0) is just returning null while min(value) is returning a value

> select percentile(HUM,0),min(HUM) from station where time >= '2015-10-11' and time < '2015-10-12' group by time(6h)
name: station
-------------
time            percentile  min
1444521600000000000         49
1444543200000000000         90
1444564800000000000         78
1444586400000000000         54
@hughescr

This comment has been minimized.

Copy link
Author

commented Oct 13, 2015

Running 87d99fb built from source using go get

@beckettsean beckettsean changed the title PERCENTILE(value,0) does not work [0.9.4] PERCENTILE(value,0) does not work, returns null instead of MIN value Oct 13, 2015

@beckettsean

This comment has been minimized.

Copy link
Contributor

commented Oct 13, 2015

Same behavior in 0.9.4.2

@beckettsean

This comment has been minimized.

Copy link
Contributor

commented Jan 5, 2016

repro on 0.9.5 in #4724

@jsternberg jsternberg changed the title [0.9.4] PERCENTILE(value,0) does not work, returns null instead of MIN value PERCENTILE(value,0) does not work, returns null instead of MIN value May 17, 2016

@jsternberg jsternberg added this to the 1.0.0 milestone May 17, 2016

@jsternberg jsternberg self-assigned this May 17, 2016

@jsternberg

This comment has been minimized.

Copy link
Contributor

commented May 18, 2016

It looks like we have an off-by-one problem with every percentile. Wolfram alpha tells me the 50th percentile of a 10 value slice should be the 5th value (4th index) (here) and it tells me the 51st percentile should be the 6th value (5th index) (here).

This ends up applying to the 0th percentile because it gets told it should access the 0th value (-1th index) and we exit if we get an invalid value like that. It looks like it's due to how the rounding and floor are being done. The rounding appears to be that it should round down on 0.5 rather than up and we currently always take the floor rather than attempting to round.

I'm going to double check this since I'm not the most familiar with percentiles.

@hughescr

This comment has been minimized.

Copy link
Author

commented May 18, 2016

Not sure how the other percentiles should work (round up vs round down vs round to nearest), but 0th percentile should be the MIN, and 100th percentile should be the MAX, always.

@jsternberg jsternberg removed this from the 1.0.0 milestone May 18, 2016

@jsternberg jsternberg removed their assignment May 20, 2016

@rbetts

This comment has been minimized.

Copy link
Contributor

commented Jan 30, 2018

We provide MIN. We require a percentile value greater than 0 or return null.

@rbetts rbetts closed this Jan 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.