[MDEV-12985] support percentile and median window functions Created: 2017-06-02 Updated: 2022-01-03 Resolved: 2017-11-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - Window functions |
| Fix Version/s: | 10.3.3 |
| Type: | Task | Priority: | Major |
| Reporter: | David Thompson (Inactive) | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Sprint: | 10.3.1-2, 10.3.3-1 | ||||||||||||||||||||||||||||||||||||
| Description |
|
The percentile_cont and percentile_disc window functions are available in columnstore and many other databases. These allow calculation of percentiles. Percentile_cont will average 2 rows if one is not identified while Percentile_disc picks the first row in the window. Finally a median function should exist which is equivalent to percentile_cont(0.5). These have slightly different syntax than other window function to specify the column: percentile_cont(0.5) within group (order by amount) over (partition by owner) pct_cont, Some investigationpercentile_cont and percentile_disc are not specifically window functions. They originally are "ordered-set aggregate functions" (#1) which one can also use as window functions (#2): Ordered-set aggreatesThe syntax for case #1:
Note the lack of OVER clause.
Ordered-set aggregates as window functionsSyntax for case #2 (ordered-set aggregate, used as window function)
(BTW: note that PostgreSQL doesn't support ordered-set-aggregates-as-window functions: https://www.postgresql.org/docs/current/static/functions-window.html ,
|
| Comments |
| Comment by Sergei Petrunia [ 2017-06-09 ] | ||||||||||||||||
|
[dthompson, a question from me and varun: Does ColumnStore need just "Ordered-set aggregates as window functions", or it needs both "Ordered-set aggregates as window functions" and "Ordered-set aggregates". IIRC it supported both? | ||||||||||||||||
| Comment by David Thompson (Inactive) [ 2017-06-09 ] | ||||||||||||||||
|
ColumnStore 1.0 supported these only as window functions (and i learned a new term!). If you can easily add as a regular aggregate that's nice to have but not required. Loop in David.Hall when you have a rough design as we will still need to reimplement the bottom end of the implementation on the columnstore side. | ||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-11 ] | ||||||||||||||||
|
| ||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-11 ] | ||||||||||||||||
|
Specification for the percentile functions
| ||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-12 ] | ||||||||||||||||
|
More specifications for the inverse distribution function argument
| ||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-14 ] | ||||||||||||||||
|
Computation for PERCENTILE_CONT
| ||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-14 ] | ||||||||||||||||
|
Computation for PERCENTILE_DISC:
| ||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-09-20 ] | ||||||||||||||||
|
Datetime fields are not supported in the first iteration of percentile functions, have created a seperate issue for it.(MDEV-13854). After MDEV-13854 , we would have datetime fields support in percentile functions | ||||||||||||||||
| Comment by Vicențiu Ciorbaru [ 2017-10-28 ] | ||||||||||||||||
|
Minor coding style fixes. Rebase and merge into 10.3 once BB clears it. | ||||||||||||||||
| Comment by Ján Regeš [ 2017-11-30 ] | ||||||||||||||||
|
@VicentiuCiorbaru - does it mean, that MEDIAN function will be in MariaDB 10.3? |