Skip to content

Commit f87405d

Browse files
committed
use interpolation computes quantile_cont
1 parent 43e4176 commit f87405d

File tree

6 files changed

+126
-214
lines changed

6 files changed

+126
-214
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/doc/15-sql-functions/10-aggregate-functions/aggregate-quantile.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: QUANTILE
44

55
Aggregate function.
66

7-
The QUANTILE() function computes the quantile of a numeric data sequence.
7+
The QUANTILE_CONT() function computes the interpolated quantile number of a numeric data sequence.
88

99
:::caution
1010
NULL values are not counted.
@@ -13,9 +13,9 @@ NULL values are not counted.
1313
## Syntax
1414

1515
```sql
16-
QUANTILE(level)(expression)
16+
QUANTILE_CONT(level)(expression)
1717

18-
QUANTILE(level1, level2, ...)(expression)
18+
QUANTILE_CONT(level1, level2, ...)(expression)
1919
```
2020

2121
## Arguments
@@ -28,28 +28,28 @@ QUANTILE(level1, level2, ...)(expression)
2828

2929
## Return Type
3030

31-
the type of the value.
31+
Float64.
3232

3333
## Examples
3434

3535
:::tip
36-
QUANTILE(0.6)(N) – A table for test with the single `number` column (UInt64) that contains integers from 0 to N-1.
36+
QUANTILE_CONT(0.6)(N) – A table for test with the single `number` column (UInt64) that contains integers from 0 to N-1.
3737
:::
3838

3939
```sql
40-
SELECT QUANTILE(0.6)(number) FROM numbers(10000);
41-
+-----------------------+
42-
| quantile(0.6)(number) |
43-
+-----------------------+
44-
| 5999 |
45-
+-----------------------+
40+
SELECT QUANTILE_CONT(0.6)(number) FROM numbers(10000);
41+
+----------------------------+
42+
| quantile_cont(0.6)(number) |
43+
+----------------------------+
44+
| 5999.4 |
45+
+----------------------------+
4646
```
4747

4848
```sql
49-
SELECT quantile(0, 0.5, 0.6, 1)(number) from numbers_mt(10000);
50-
+----------------------------------+
51-
| quantile(0, 0.5, 0.6, 1)(number) |
52-
+----------------------------------+
53-
| [0,4999,5999,9999] |
54-
+----------------------------------+
49+
SELECT QUANTILE_CONT(0, 0.5, 0.6, 1)(number) FROM numbers_mt(10000);
50+
+---------------------------------------+
51+
| quantile_cont(0, 0.5, 0.6, 1)(number) |
52+
+---------------------------------------+
53+
| [0.0,4999.5,5999.4,9999.0] |
54+
+---------------------------------------+
5555
```

src/query/functions/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ h3o = "0.3.0"
3636
hex = "0.4.3"
3737
itertools = "0.10.5"
3838
lexical-core = "0.8.5"
39+
libm = "0.2.6"
3940
match-template = "0.0.1"
4041
md-5 = "0.10.5"
4142
memchr = { version = "2", default-features = false }

0 commit comments

Comments
 (0)