mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
more tests for CTE #16575
This commit is contained in:
parent
973c1d7983
commit
eedf4439bb
@ -0,0 +1,26 @@
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
1
|
||||
1
|
||||
3
|
||||
3
|
||||
1
|
||||
3
|
@ -0,0 +1,49 @@
|
||||
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5))
|
||||
SELECT * FROM x WHERE a in (SELECT a FROM y)
|
||||
ORDER BY a;
|
||||
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5))
|
||||
SELECT * FROM x left JOIN y USING a
|
||||
ORDER BY a;
|
||||
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5))
|
||||
SELECT * FROM x JOIN y USING a
|
||||
ORDER BY x.a;
|
||||
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT toUInt64(1) b)
|
||||
SELECT * FROM x JOIN y USING a WHERE a in (SELECT * FROM z);
|
||||
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT * FROM x WHERE a % 2),
|
||||
w AS (SELECT * FROM y WHERE a > 0)
|
||||
SELECT * FROM x JOIN y USING a WHERE a in (SELECT * FROM z)
|
||||
ORDER BY x.a;
|
||||
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT * FROM x WHERE a % 2),
|
||||
w AS (SELECT * FROM y WHERE a > 0)
|
||||
SELECT max(a) FROM x JOIN y USING a WHERE a in (SELECT * FROM z)
|
||||
HAVING a > (SELECT min(a) FROM w);
|
||||
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT * FROM x WHERE a % 2),
|
||||
w AS (SELECT * FROM y WHERE a > 0)
|
||||
SELECT a FROM x JOIN y USING a WHERE a in (SELECT * FROM z)
|
||||
HAVING a <= (SELECT max(a) FROM w)
|
||||
ORDER BY x.a;
|
@ -0,0 +1,8 @@
|
||||
4999
|
||||
333
|
||||
3333
|
||||
2000
|
||||
97 1 33
|
||||
99 -3299 3399
|
||||
99 0 100
|
||||
99 -3299 3399
|
@ -0,0 +1,82 @@
|
||||
DROP TABLE IF EXISTS cte1;
|
||||
DROP TABLE IF EXISTS cte2;
|
||||
|
||||
CREATE TABLE cte1(a Int64) ENGINE=Memory;
|
||||
CREATE TABLE cte2(a Int64) ENGINE=Memory;
|
||||
|
||||
INSERT INTO cte1 SELECT * FROM numbers(10000);
|
||||
INSERT INTO cte2 SELECT * FROM numbers(5000);
|
||||
|
||||
WITH
|
||||
x AS (SELECT * FROM cte1),
|
||||
y AS (SELECT * FROM cte2),
|
||||
z AS (SELECT * FROM x WHERE a % 2 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333)
|
||||
SELECT max(a)
|
||||
FROM x JOIN y USING (a)
|
||||
WHERE a in (SELECT * FROM z) AND a <= (SELECT max(a) FROM w);
|
||||
|
||||
WITH
|
||||
x AS (SELECT * FROM cte1),
|
||||
y AS (SELECT * FROM cte2),
|
||||
z AS (SELECT * FROM x WHERE a % 3 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333 AND a < 1000)
|
||||
SELECT count(a)
|
||||
FROM x left JOIN y USING (a)
|
||||
WHERE a in (SELECT * FROM z) AND a <= (SELECT max(a) FROM w);
|
||||
|
||||
WITH
|
||||
x AS (SELECT * FROM cte1),
|
||||
y AS (SELECT * FROM cte2),
|
||||
z AS (SELECT * FROM x WHERE a % 3 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333 AND a < 1000)
|
||||
SELECT count(a)
|
||||
FROM x left JOIN y USING (a)
|
||||
WHERE a in (SELECT * FROM z);
|
||||
|
||||
WITH
|
||||
x AS (SELECT a-4000 a FROM cte1 WHERE cte1.a >700),
|
||||
y AS (SELECT * FROM cte2),
|
||||
z AS (SELECT * FROM x WHERE a % 3 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333 AND a < 1000)
|
||||
SELECT count(*)
|
||||
FROM x left JOIN y USING (a)
|
||||
WHERE a in (SELECT * FROM z);
|
||||
|
||||
WITH
|
||||
x AS (SELECT a-4000 a FROM cte1 WHERE cte1.a >700),
|
||||
y AS (SELECT * FROM cte2),
|
||||
z AS (SELECT * FROM x WHERE a % 3 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333 AND a < 1000)
|
||||
SELECT max(a), min(a), count(*)
|
||||
FROM x
|
||||
WHERE a in (SELECT * FROM z) AND a <100;
|
||||
|
||||
WITH
|
||||
x AS (SELECT a-4000 a FROM cte1 WHERE cte1.a >700),
|
||||
y AS (SELECT * FROM cte2),
|
||||
z AS (SELECT * FROM x WHERE a % 3 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333 AND a < 1000)
|
||||
SELECT max(a), min(a), count(*) FROM x
|
||||
WHERE a <100;
|
||||
|
||||
WITH
|
||||
x AS (SELECT a-4000 a FROM cte1 AS t WHERE cte1.a >700),
|
||||
y AS (SELECT * FROM cte2),
|
||||
z AS (SELECT * FROM x WHERE a % 3 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333 AND a < 1000)
|
||||
SELECT max(a), min(a), count(*)
|
||||
FROM y
|
||||
WHERE a <100;
|
||||
|
||||
WITH
|
||||
x AS (SELECT a-4000 a FROM cte1 t WHERE t.a >700),
|
||||
y AS (SELECT x.a a FROM x left JOIN cte1 USING (a)),
|
||||
z AS (SELECT * FROM x WHERE a % 3 = 1),
|
||||
w AS (SELECT * FROM y WHERE a > 333 AND a < 1000)
|
||||
SELECT max(a), min(a), count(*)
|
||||
FROM y
|
||||
WHERE a <100;
|
||||
|
||||
DROP TABLE cte1;
|
||||
DROP TABLE cte2;
|
Loading…
Reference in New Issue
Block a user