[MDEV-9925] Wrong result with aggregate function as a window function Created: 2016-04-14  Updated: 2016-04-15  Resolved: 2016-04-15

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

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Petrunia
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-9896 Testing for window functions Open

 Description   

create table t4 (i int);
insert into t4 values (1),(2);
select i, sum(i) over (partition by i) from t4;

Actual result

+------+------------------------------+
| i    | sum(i) over (partition by i) |
+------+------------------------------+
|    1 |                            3 |
|    2 |                            2 |
+------+------------------------------+
2 rows in set (0.00 sec)

Expected result

postgres=# select i, sum(i) over (partition by i) from t4;
 i | sum 
---+-----
 1 |   1
 2 |   2
(2 rows)

If I add ORDER BY, the result becomes correct:

MariaDB [test]> select i, sum(i) over (partition by i order by i) from t4;
+------+-----------------------------------------+
| i    | sum(i) over (partition by i order by i) |
+------+-----------------------------------------+
|    1 |                                       1 |
|    2 |                                       2 |
+------+-----------------------------------------+
2 rows in set (0.00 sec)



 Comments   
Comment by Sergei Petrunia [ 2016-04-15 ]

Fix pushed into the feature tree.

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