mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 10:31:57 +00:00
Test join_use_nulls in 01881_join_on_conditions
This commit is contained in:
parent
d37b88fb07
commit
fc6b8ed655
@ -1,120 +0,0 @@
|
||||
-- hash_join --
|
||||
--
|
||||
222 2
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222
|
||||
333
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
--
|
||||
2
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
--
|
||||
222 2
|
||||
333 3
|
||||
222 2
|
||||
333 3
|
||||
--
|
||||
0 2 AAA a
|
||||
0 4 CCC CCC
|
||||
1 111 111 0
|
||||
2 222 2 0
|
||||
2 222 222 2 AAA AAA
|
||||
3 333 333 3 BBB BBB
|
||||
0 4 101 CCC CCC
|
||||
1 111 111 2 1 AAA AAA
|
||||
2 222 2 0 0
|
||||
2 222 222 2 1 AAA AAA
|
||||
3 333 333 2 3 AAA a
|
||||
3 333 333 3 100 BBB BBB
|
||||
2 222 2 2 AAA AAA
|
||||
2 222 222 2 AAA AAA
|
||||
3 333 333 3 BBB BBB
|
||||
--
|
||||
2 222 2 2 AAA a
|
||||
2 222 222 2 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
-- partial_merge --
|
||||
--
|
||||
222 2
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222
|
||||
333
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
--
|
||||
2
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
--
|
||||
222 2
|
||||
333 3
|
||||
222 2
|
||||
333 3
|
||||
--
|
||||
0 2 AAA a
|
||||
0 4 CCC CCC
|
||||
1 111 111 0
|
||||
2 222 2 0
|
||||
2 222 222 2 AAA AAA
|
||||
3 333 333 3 BBB BBB
|
||||
--
|
||||
2 222 2 2 AAA a
|
||||
2 222 222 2 AAA AAA
|
126
tests/queries/0_stateless/01881_join_on_conditions.reference.j2
Normal file
126
tests/queries/0_stateless/01881_join_on_conditions.reference.j2
Normal file
@ -0,0 +1,126 @@
|
||||
{%- macro jnull(join_use_nulls, value='') -%}
|
||||
{#- default value or null if join_use_nulls is enabled -#}
|
||||
{% if join_use_nulls == 1 %}\N{% else %}{{ value }}{% endif %}
|
||||
{%- endmacro -%}
|
||||
{% for jn in [0, 1] -%}
|
||||
-- hash_join --
|
||||
--
|
||||
222 2
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222
|
||||
333
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
--
|
||||
2
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
--
|
||||
222 2
|
||||
333 3
|
||||
222 2
|
||||
333 3
|
||||
--
|
||||
{{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }} 2 AAA a
|
||||
{{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }} 4 CCC CCC
|
||||
1 111 111 {{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }}
|
||||
2 222 2 {{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }}
|
||||
2 222 222 2 AAA AAA
|
||||
3 333 333 3 BBB BBB
|
||||
{{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }} 4 101 CCC CCC
|
||||
1 111 111 2 1 AAA AAA
|
||||
2 222 2 {{ jnull(jn, 0) }} {{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }}
|
||||
2 222 222 2 1 AAA AAA
|
||||
3 333 333 2 3 AAA a
|
||||
3 333 333 3 100 BBB BBB
|
||||
2 222 2 2 AAA AAA
|
||||
2 222 222 2 AAA AAA
|
||||
3 333 333 3 BBB BBB
|
||||
--
|
||||
2 222 2 2 AAA a
|
||||
2 222 222 2 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
t22 1 111 111 2 1 AAA AAA
|
||||
-- partial_merge --
|
||||
--
|
||||
222 2
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222 222
|
||||
333 333
|
||||
--
|
||||
222
|
||||
333
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
--
|
||||
2
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
2
|
||||
3
|
||||
--
|
||||
222 2
|
||||
333 3
|
||||
222 2
|
||||
333 3
|
||||
--
|
||||
{{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }} 2 AAA a
|
||||
{{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }} 4 CCC CCC
|
||||
1 111 111 {{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }}
|
||||
2 222 2 {{ jnull(jn, 0) }} {{ jnull(jn) }} {{ jnull(jn) }}
|
||||
2 222 222 2 AAA AAA
|
||||
3 333 333 3 BBB BBB
|
||||
--
|
||||
2 222 2 2 AAA a
|
||||
2 222 222 2 AAA AAA
|
||||
{% endfor -%}
|
@ -15,6 +15,12 @@ INSERT INTO t2_nullable VALUES (2, 'AAA', 'AAA'),(2, 'AAA', 'a'),(3, 'BBB', NULL
|
||||
INSERT INTO t2_lc VALUES (2, 'AAA', 'AAA'),(2, 'AAA', 'a'),(3, 'BBB', 'BBB'),(4, 'CCC', 'CCC');
|
||||
INSERT INTO t22 VALUES (2, 1, 'AAA', 'AAA'),(2, 3, 'AAA', 'a'),(3, 100, 'BBB', 'BBB'),(4, 101, 'CCC', 'CCC');
|
||||
|
||||
{% for join_use_nulls in [0, 1] -%}
|
||||
|
||||
SET join_use_nulls = {{ join_use_nulls }};
|
||||
|
||||
SET join_algorithm = 'hash';
|
||||
|
||||
SELECT '-- hash_join --';
|
||||
|
||||
SELECT '--';
|
||||
@ -56,8 +62,8 @@ SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id =
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toUInt8(e + 1);
|
||||
|
||||
SELECT '--';
|
||||
SELECT t1.id, t1.key, t1.key2, t2.id, t2.key, t2.key2 FROM t1 FULL JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 ORDER BY t1.id, t2.id;
|
||||
SELECT t1.id, t1.key, t1.key2, t22.id, t22.idd, t22.key, t22.key2 FROM t1 FULL JOIN t22 ON t1.id == t22.id AND t22.key == t22.key2 AND t1.key == t1.key2 OR t1.id = t22.idd AND t1.key = t1.key2 ORDER BY t1.id, t22.id;
|
||||
SELECT t1.id, t1.key, t1.key2, t2.id, t2.key, t2.key2 FROM t1 FULL JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 ORDER BY t1.id NULLS FIRST, t2.id NULLS FIRST;
|
||||
SELECT t1.id, t1.key, t1.key2, t22.id, t22.idd, t22.key, t22.key2 FROM t1 FULL JOIN t22 ON t1.id == t22.id AND t22.key == t22.key2 AND t1.key == t1.key2 OR t1.id = t22.idd AND t1.key = t1.key2 ORDER BY t1.id NULLS FIRST, t22.id NULLS FIRST;
|
||||
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.id; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.id; -- { serverError 403 }
|
||||
@ -124,7 +130,7 @@ SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id =
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toUInt8(e + 1);
|
||||
|
||||
SELECT '--';
|
||||
SELECT t1.id, t1.key, t1.key2, t2.id, t2.key, t2.key2 FROM t1 FULL JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 ORDER BY t1.id, t2.id;
|
||||
SELECT t1.id, t1.key, t1.key2, t2.id, t2.key, t2.key2 FROM t1 FULL JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 ORDER BY t1.id NULLS FIRST, t2.id NULLS FIRST;
|
||||
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.id; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.id; -- { serverError 403 }
|
||||
@ -143,6 +149,9 @@ SELECT '--';
|
||||
-- length(t1.key2) == length(t2.key2) is expression for columns from both tables, it works because it part of joining key
|
||||
SELECT t1.*, t2.* FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND length(t1.key2) == length(t2.key2) AND t1.key != '333';
|
||||
|
||||
|
||||
{% endfor -%}
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
DROP TABLE IF EXISTS t2_nullable;
|
Loading…
Reference in New Issue
Block a user