[MCOL-975] query validation incorrect for complex order by Created: 2017-10-13  Updated: 2020-01-30  Resolved: 2020-01-30

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: 1.0.11, 1.1.0
Fix Version/s: 1.4.3

Type: Bug Priority: Major
Reporter: David Thompson (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 2
Labels: None


 Description   

The following query fails to parse though should work and does with innodb. Replacing the expression in the order by with the column alias is a workaround (2nd query). It would appear the validation is not correctly detecting the expression as an aggregate.

CREATE TABLE testcolumnstore(
id BIGINT,
integerfield INT,
integerfield2 INT
)
ENGINE=Columnstore;
 
 
insert into testcolumnstore values(1,null,1);
insert into testcolumnstore values(1,null,1);
insert into testcolumnstore values(2,null,1);
 
 
select id,
SUM(integerfield) sum1,
SUM(integerfield2) sum2,
ifnull(SUM(integerfield),0)+ifnull(SUM(integerfield2),0) sum3
from testcolumnstore
group by id
order by ifnull(SUM(integerfield),0)+ifnull(SUM(integerfield2),0);
 
ERROR 1815 (HY000): Internal error: IDB-2021: 'test.testcolumnstore.integerfield' is not in GROUP BY clause. All non-aggregate columns in the SELECT and ORDER BY clause must be included in the GROUP BY clause.
 
 
select id,
SUM(integerfield) sum1,
SUM(integerfield2) sum2,
ifnull(SUM(integerfield),0)+ifnull(SUM(integerfield2),0) sum3
from testcolumnstore
group by id
order by sum3;
 
+------+------+------+------+
| id   | sum1 | sum2 | sum3 |
+------+------+------+------+
|    2 | NULL | 1    | 1    |
|    1 | NULL | 2    | 2    |
+------+------+------+------+
2 rows in set (0.01 sec)


Generated at Thu Feb 08 02:25:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.