[MDEV-12839] incorrect lead window function value with null Created: 2017-05-18 Updated: 2018-06-14 Resolved: 2017-05-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - Window functions |
| Affects Version/s: | 10.2.5 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | David Thompson (Inactive) | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | need_feedback | ||
| Description |
|
when you have a null in the value being windowed over this is being put at the end but the lead value is the first value in the window rather than null. I believe it should be null. If you don't have any nulls it behaves this way. This would also be a regression for columnstore 1.1. Steps to repro:
|
| Comments |
| Comment by Elena Stepanova [ 2017-05-18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It is put at the end because you don't specify any order, it could be different in other circumstances, e.g.:
or
Given that, do you still think it works incorrectly? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Thompson (Inactive) [ 2017-05-18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hmmn thinking about it, i think the behavior would be explained by the window function order being nulls first? My understanding is that the window function order by is distinct from the select order by as well so it shouldn't matter how you order the select. However i thought the default 'mysql way' is nulls last. I couldn't find anything in the kb article. So if the defined behavior of windows functions in 10.2 is that nulls come first then this is not a bug and can be closed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-05-18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I"m not sure I've understood correctly this part "My understanding is that the window function order by is distinct from the select order by as well" ; but if I'm guessing right and you mean that ORDER BY in the window definition also defines the order of the resultset – it doesn't, they are independent.
etc. For NULLs, the default "mysql way" is nulls first.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Thompson (Inactive) [ 2017-05-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, correct i was thrown by the separate table order so this is behaving as intended. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Corbin Bohne [ 2018-06-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Agree with all here that this is expected behavior. |