[MCOL-5463] Columnstore throws error when using GROUP BY on DB-Views where field name is identical in two different tables Created: 2023-03-28  Updated: 2023-12-15  Resolved: 2023-12-15

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: None
Fix Version/s: 23.10.1

Type: Bug Priority: Critical
Reporter: andreas eschbacher Assignee: Allen Herrera
Resolution: Fixed Votes: 0
Labels: triage, views
Environment:

CS 5.6.8 MariaDB 10.5.18 RHEL 8.5


Sprint: 2023-11

 Description   

– COLUMNSTORE throws error:
– =========================
create table t1
(
id int,
someStr varchar(100)
) ENGINE=Columnstore;

create table t2
(
id int,
fk_t1 int,
someStr varchar(100)
) ENGINE=Columnstore;

insert into t1 values (1, 'bla');
insert into t2 values (1, 1, 'xyz');

create view view_on_t1 as select id, someStr from t1;
create view view_on_t2 as select id, fk_t1, someStr from t2;

– ERROR !!!
select max(view_on_t1.id), view_on_t1.someStr, view_on_t2.someStr
from view_on_t1
left outer join view_on_t2
on view_on_t1.id = view_on_t2.fk_t1
group by view_on_t1.someStr, view_on_t2.someStr;
– ==> All non-aggregate columns in the SELECT and ORDER BY clause must be included in the GROUP BY clause. 0.063 sec

– working on tables directly it works however:
select max(t1.id), t1.someStr, t2.someStr
from t1
left outer join t2
on t1.id = t2.fk_t1
group by t1.someStr, t2.someStr;

– INNODB
– ======
create table t1_innodb
(
id int,
someStr varchar(100)
) ENGINE=InnoDB;

create table t2_innodb
(
id int,
fk_t1 int,
someStr varchar(100)
) ENGINE=InnoDB;

insert into t1_innodb values (1, 'bla');
insert into t2_innodb values (1, 1, 'xyz');

create view view_on_t1_innodb as select id, someStr from t1_innodb;
create view view_on_t2_innodb as select id, fk_t1, someStr from t2_innodb;

– works:
select max(view_on_t1_innodb.id), view_on_t1_innodb.someStr, view_on_t2_innodb.someStr
from view_on_t1_innodb
left outer join view_on_t2_innodb
on view_on_t1_innodb.id = view_on_t2_innodb.fk_t1
group by view_on_t1_innodb.someStr, view_on_t2_innodb.someStr;



 Comments   
Comment by Allen Herrera [ 2023-06-12 ]

Use alias' or dont use views

MariaDB [test]> select max(view_on_t1.id) as a, view_on_t1.someStr as b, view_on_t2.someStr as c
    -> from view_on_t1
    -> left outer join view_on_t2
    -> on view_on_t1.id = view_on_t2.fk_t1
    -> group by b, c;
+------+------+------+
| a    | b    | c    |
+------+------+------+
|    1 | bla  | xyz  |
+------+------+------+
1 row in set (0.026 sec)

MariaDB [test]> select max(t1.id), t1.someStr, t2.someStr
    -> from t1
    -> left outer join t2
    -> on t1.id = t2.fk_t1
    -> group by t1.someStr, t2.someStr;
+------------+---------+---------+
| max(t1.id) | someStr | someStr |
+------------+---------+---------+
|          1 | bla     | xyz     |
+------------+---------+---------+
1 row in set (0.040 sec)

Comment by Maria M Pflaum [ 2023-06-13 ]

Customer replies that this is not a solution for them because the select will be generated by a third party software.

Comment by Kirill Perov [ 2023-12-02 ]

MCS query is not failing.

testing finished ok.

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