[MDEV-9951] Wrong windowing functions results with duplicate values Created: 2016-04-19 Updated: 2016-04-20 Resolved: 2016-04-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - Window functions |
| Affects Version/s: | 10.2.0 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Federico Razzoli | Assignee: | Sergei Petrunia |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
When using an aggregate function as a running function (SUM(...) OVER (...)), identical values are processed together. Which means, if you sum 1 three times, you will get 3 in all records.
|
| Comments |
| Comment by Elena Stepanova [ 2016-04-20 ] |
|
I think that's how it's supposed to work.
f_razzoli, does it explain the results you are getting, or did you mean something else that I've missed? |
| Comment by Federico Razzoli [ 2016-04-20 ] |
|
You are not missing anything. I didn't know that this is standard behaviour. Honestly I can't imagine the reason. |
| Comment by Elena Stepanova [ 2016-04-20 ] |
|
I think "by default" here relates to the first part, "the frame consists of all rows from the start of the partition up through the current row", in other words, omitting the explicit range means that RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW will be used. I doubt that the behavior with this particular query can be changed, although you can get more sensible results playing with the query itself; and the query where you only select a non-unique column, order by it and aggregate it at the same time is probably not very realistic anyway. But I will re-address your question to psergey, the expert in the area. |
| Comment by Sergei Petrunia [ 2016-04-20 ] |
|
>in other words, omitting the explicit range means that RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW will be used. Confirm, that's how it works. f_razzoli , As far as I understand, ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW is what you're looking for. |
| Comment by Sergei Petrunia [ 2016-04-20 ] |
|
Closing as the behaviour is as expected. |