[MDEV-9911] NTILE must return an error when parameter is not stable Created: 2016-04-13  Updated: 2020-07-28  Resolved: 2020-07-28

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions, Server
Affects Version/s: N/A
Fix Version/s: 10.2.33

Type: Bug Priority: Major
Reporter: Vicențiu Ciorbaru Assignee: Anel Husakovic
Resolution: Fixed Votes: 0
Labels: beginner-friendly

Issue Links:
PartOf
is part of MDEV-6115 window functions as in the SQL standard Closed
Sprint: 10.2.6-2, 10.2.6-3

 Description   

Ntile must only work for deterministic cases.

If we have a query such as

select ntile( n ) over (partition by c1 order by c2):

n must provide a stable value for every individual partition, or we should return an error.

Currently we compute

 ntile(<current_value_of_n>) 

, given the current row number in the partition. This leads to erroneous results.



 Comments   
Comment by Dan Solodko [ 2020-06-11 ]

if it's possible to use an error ER_INVALID_NTILE_ARGUMENT for unstable argument I'm ready to create a Pull Reqest

Comment by Anel Husakovic [ 2020-07-28 ]

Pushed to 10.2 with 459b87f6b4ae96.
Thanks

Generated at Thu Feb 08 07:38:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.