Add join_on_or_long.sql

This commit is contained in:
vdimir 2021-09-13 12:34:02 +03:00 committed by Ilya Golshtein
parent f8e8f6da14
commit 212ba1b64f
2 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,64 @@
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

View File

@ -0,0 +1,43 @@
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1 (`a` Int64, `b` Int64) ENGINE = MergeTree() ORDER BY a;
CREATE TABLE t2 (`key` Int32, `val` Int64) ENGINE = MergeTree() ORDER BY key;
INSERT INTO t1 SELECT number + 500 as a, -a as b from numbers(1000);
INSERT INTO t2 SELECT if(number % 2 == 0, toInt64(number), -number) as key, number as val from numbers(1000);
{% for bs in [99, 100, 101, 127, 128, 129, 256, 2048] -%}
SET max_block_size = {{ bs }};
SET join_use_nulls = 1;
SELECT count() == 500 AND count(a) == 500 AND sum(a) == 1499 * 500 / 2 FROM (
SELECT a, b, val FROM t1 INNER JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
SELECT count() == 1000 AND count(val) == 500 AND sum(val) == 1499 * 500 / 2 FROM (
SELECT a, b, val FROM t1 LEFT JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
SELECT count() == 1000 AND count(a) == 500 AND sum(val) == 999 * 1000 / 2 FROM (
SELECT * FROM t1 RIGHT JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
SELECT count() == 1500 AND count(a) == 1000 AND count(val) = 1000 AND sum(val) == 999 * 1000 / 2 AND sum(a) == 1999 * 1000 / 2 FROM (
SELECT a, b, val FROM t1 FULL JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
SET join_use_nulls = 0;
SELECT count() == 500 AND count(a) == 500 AND sum(a) == 1499 * 500 / 2 FROM (
SELECT a, b, val FROM t1 INNER JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
SELECT count() == 1000 AND count(val) == 1000 AND sum(val) == 1499 * 500 / 2 FROM (
SELECT a, b, val FROM t1 LEFT JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
SELECT count() == 1000 AND count(a) == 1000 AND sum(val) == 999 * 1000 / 2 FROM (
SELECT * FROM t1 RIGHT JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
SELECT count() == 1500 AND count(a) == 1500 AND count(val) = 1500 AND sum(val) == 999 * 1000 / 2 AND sum(a) == 1999 * 1000 / 2 FROM (
SELECT a, b, val FROM t1 FULL JOIN t2 ON t1.a = t2.key OR t1.b = t2.key);
{% endfor %}