mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Added a test for multiple JOINs from Denny Crane #4571
This commit is contained in:
parent
1454479713
commit
3e8d9ec450
@ -0,0 +1,2 @@
|
||||
CAT 2
|
||||
CAT 2
|
@ -0,0 +1,40 @@
|
||||
USE test;
|
||||
|
||||
DROP TABLE IF EXISTS ANIMAL;
|
||||
|
||||
CREATE TABLE ANIMAL ( ANIMAL Nullable(String) ) engine = TinyLog;
|
||||
INSERT INTO ANIMAL (ANIMAL) VALUES ('CAT'), ('FISH'), ('DOG'), ('HORSE'), ('BIRD');
|
||||
|
||||
set enable_optimize_predicate_expression = 0;
|
||||
|
||||
select * from (
|
||||
select x.b x, count(distinct x.c) ANIMAL
|
||||
from (
|
||||
select a.ANIMAL a, 'CAT' b, c.ANIMAL c, d.ANIMAL d
|
||||
from ANIMAL a join ANIMAL b on a.ANIMAL = b.ANIMAL
|
||||
left outer join ANIMAL c on (b.ANIMAL = c.ANIMAL)
|
||||
right outer join (select * from ANIMAL union all select * from ANIMAL
|
||||
union all select * from ANIMAL) d on (a.ANIMAL = d.ANIMAL)
|
||||
where d.ANIMAL <> 'CAT' and c.ANIMAL <>'DOG' and b.ANIMAL <> 'FISH') as x
|
||||
where x.b >= 'CAT'
|
||||
group by x.b
|
||||
having ANIMAL >= 0) ANIMAL
|
||||
where ANIMAL.ANIMAL >= 0;
|
||||
|
||||
set enable_optimize_predicate_expression = 1;
|
||||
|
||||
select * from (
|
||||
select x.b x, count(distinct x.c) ANIMAL
|
||||
from (
|
||||
select a.ANIMAL a, 'CAT' b, c.ANIMAL c, d.ANIMAL d
|
||||
from ANIMAL a join ANIMAL b on a.ANIMAL = b.ANIMAL
|
||||
left outer join ANIMAL c on (b.ANIMAL = c.ANIMAL)
|
||||
right outer join (select * from ANIMAL union all select * from ANIMAL
|
||||
union all select * from ANIMAL) d on (a.ANIMAL = d.ANIMAL)
|
||||
where d.ANIMAL <> 'CAT' and c.ANIMAL <>'DOG' and b.ANIMAL <> 'FISH') as x
|
||||
where x.b >= 'CAT'
|
||||
group by x.b
|
||||
having ANIMAL >= 0) ANIMAL
|
||||
where ANIMAL.ANIMAL >= 0;
|
||||
|
||||
DROP TABLE ANIMAL;
|
Loading…
Reference in New Issue
Block a user