mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix crash in StorageJoin (add restriction)
This commit is contained in:
parent
458f596e18
commit
6b80ba52be
@ -73,6 +73,10 @@ HashJoinPtr StorageJoin::getJoin(std::shared_ptr<AnalyzedJoin> analyzed_join) co
|
||||
if (kind != analyzed_join->kind() || strictness != analyzed_join->strictness())
|
||||
throw Exception("Table " + table_name + " has incompatible type of JOIN.", ErrorCodes::INCOMPATIBLE_TYPE_OF_JOIN);
|
||||
|
||||
if (analyzed_join->forceNullableRight() && !use_nulls)
|
||||
throw Exception("Table " + table_name + " need join_use_nulls settings to support LEFT or FULL JOIN with join_use_nulls.",
|
||||
ErrorCodes::INCOMPATIBLE_TYPE_OF_JOIN);
|
||||
|
||||
/// TODO: check key columns
|
||||
|
||||
/// Some HACK to remove wrong names qualifiers: table.column -> column.
|
||||
|
@ -30,3 +30,48 @@ full
|
||||
4 a5 b4
|
||||
4 a5 b5
|
||||
5 b6
|
||||
inner (join_use_nulls mix)
|
||||
2 a3 b1
|
||||
2 a3 b2
|
||||
4 a5 b3
|
||||
4 a5 b4
|
||||
4 a5 b5
|
||||
right (join_use_nulls mix)
|
||||
2 a3 b1
|
||||
2 a3 b2
|
||||
4 a5 b3
|
||||
4 a5 b4
|
||||
4 a5 b5
|
||||
5 \N b6
|
||||
left (join_use_nulls)
|
||||
0 a1 \N
|
||||
1 a2 \N
|
||||
2 a3 b1
|
||||
2 a3 b2
|
||||
3 a4 \N
|
||||
4 a5 b3
|
||||
4 a5 b4
|
||||
4 a5 b5
|
||||
inner (join_use_nulls)
|
||||
2 a3 b1
|
||||
2 a3 b2
|
||||
4 a5 b3
|
||||
4 a5 b4
|
||||
4 a5 b5
|
||||
right (join_use_nulls)
|
||||
2 a3 b1
|
||||
2 a3 b2
|
||||
4 a5 b3
|
||||
4 a5 b4
|
||||
4 a5 b5
|
||||
5 \N b6
|
||||
full (join_use_nulls)
|
||||
0 a1 \N
|
||||
1 a2 \N
|
||||
2 a3 b1
|
||||
2 a3 b2
|
||||
3 a4 \N
|
||||
4 a5 b3
|
||||
4 a5 b4
|
||||
4 a5 b5
|
||||
5 \N b6
|
||||
|
@ -33,20 +33,43 @@ SELECT * FROM t1 RIGHT JOIN right_join j USING(x) ORDER BY x, str, s;
|
||||
SELECT 'full';
|
||||
SELECT * FROM t1 FULL JOIN full_join j USING(x) ORDER BY x, str, s;
|
||||
|
||||
-- TODO
|
||||
-- SET join_use_nulls = 1;
|
||||
--
|
||||
-- SELECT 'left (join_use_nulls)';
|
||||
-- SELECT * FROM t1 LEFT JOIN left_join j USING(x) ORDER BY x, str, s;
|
||||
--
|
||||
-- SELECT 'inner (join_use_nulls)';
|
||||
-- SELECT * FROM t1 INNER JOIN inner_join j USING(x) ORDER BY x, str, s;
|
||||
--
|
||||
-- SELECT 'right (join_use_nulls)';
|
||||
-- SELECT * FROM t1 RIGHT JOIN right_join j USING(x) ORDER BY x, str, s;
|
||||
--
|
||||
-- SELECT 'full (join_use_nulls)';
|
||||
-- SELECT * FROM t1 FULL JOIN full_join j USING(x) ORDER BY x, str, s;
|
||||
SET join_use_nulls = 1;
|
||||
|
||||
SELECT * FROM t1 LEFT JOIN left_join j USING(x) ORDER BY x, str, s; -- { serverError 264 }
|
||||
SELECT * FROM t1 FULL JOIN full_join j USING(x) ORDER BY x, str, s; -- { serverError 264 }
|
||||
|
||||
SELECT 'inner (join_use_nulls mix)';
|
||||
SELECT * FROM t1 INNER JOIN inner_join j USING(x) ORDER BY x, str, s;
|
||||
|
||||
SELECT 'right (join_use_nulls mix)';
|
||||
SELECT * FROM t1 RIGHT JOIN right_join j USING(x) ORDER BY x, str, s;
|
||||
|
||||
DROP TABLE left_join;
|
||||
DROP TABLE inner_join;
|
||||
DROP TABLE right_join;
|
||||
DROP TABLE full_join;
|
||||
|
||||
CREATE TABLE left_join (x UInt32, s String) engine = Join(ALL, LEFT, x) SETTINGS join_use_nulls = 1;
|
||||
CREATE TABLE inner_join (x UInt32, s String) engine = Join(ALL, INNER, x) SETTINGS join_use_nulls = 1;
|
||||
CREATE TABLE right_join (x UInt32, s String) engine = Join(ALL, RIGHT, x) SETTINGS join_use_nulls = 1;
|
||||
CREATE TABLE full_join (x UInt32, s String) engine = Join(ALL, FULL, x) SETTINGS join_use_nulls = 1;
|
||||
|
||||
INSERT INTO left_join (x, s) VALUES (2, 'b1'), (2, 'b2'), (4, 'b3'), (4, 'b4'), (4, 'b5'), (5, 'b6');
|
||||
INSERT INTO inner_join (x, s) VALUES (2, 'b1'), (2, 'b2'), (4, 'b3'), (4, 'b4'), (4, 'b5'), (5, 'b6');
|
||||
INSERT INTO right_join (x, s) VALUES (2, 'b1'), (2, 'b2'), (4, 'b3'), (4, 'b4'), (4, 'b5'), (5, 'b6');
|
||||
INSERT INTO full_join (x, s) VALUES (2, 'b1'), (2, 'b2'), (4, 'b3'), (4, 'b4'), (4, 'b5'), (5, 'b6');
|
||||
|
||||
SELECT 'left (join_use_nulls)';
|
||||
SELECT * FROM t1 LEFT JOIN left_join j USING(x) ORDER BY x, str, s;
|
||||
|
||||
SELECT 'inner (join_use_nulls)';
|
||||
SELECT * FROM t1 INNER JOIN inner_join j USING(x) ORDER BY x, str, s;
|
||||
|
||||
SELECT 'right (join_use_nulls)';
|
||||
SELECT * FROM t1 RIGHT JOIN right_join j USING(x) ORDER BY x, str, s;
|
||||
|
||||
SELECT 'full (join_use_nulls)';
|
||||
SELECT * FROM t1 FULL JOIN full_join j USING(x) ORDER BY x, str, s;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user