[MDEV-17525] Window functions not working in ONLY_FULL_GROUP_BY mode Created: 2018-10-23  Updated: 2018-10-31  Resolved: 2018-10-26

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.3.9, 10.2, 10.3
Fix Version/s: 10.3.11, 10.2.19

Type: Bug Priority: Major
Reporter: Jonas Staudenmeir Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 2
Labels: None
Environment:

Ubuntu 18.04.1



 Description   

Window functions don't seem to work in ONLY_FULL_GROUP_BY mode.

Using the example queries from the documentation:

CREATE TABLE student (name CHAR(10), test CHAR(10), score TINYINT); 
 
INSERT INTO student VALUES 
  ('Chun', 'SQL', 75), ('Chun', 'Tuning', 73), 
  ('Esben', 'SQL', 43), ('Esben', 'Tuning', 31), 
  ('Kaolin', 'SQL', 56), ('Kaolin', 'Tuning', 88), 
  ('Tatiana', 'SQL', 87), ('Tatiana', 'Tuning', 83);
 
SET sql_mode = 'ONLY_FULL_GROUP_BY';
 
SELECT name, test, score,
  AVG(score) OVER (PARTITION BY test) AS average_by_test
FROM student;

The SELECT query fails with an error:

ERROR 1055 (42000): 'database.student.name' isn't in GROUP BY

From my understanding, this is a valid query. It works on MySQL 8.0 (fiddle) and PostgreSQL (fiddle).



 Comments   
Comment by Varun Gupta (Inactive) [ 2018-10-24 ]

Patch
http://lists.askmonty.org/pipermail/commits/2018-October/013038.html

Comment by Sergei Petrunia [ 2018-10-25 ]

Ok to push.

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