mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
better engine Join tests
This commit is contained in:
parent
b75771be61
commit
3e13157994
@ -140,35 +140,36 @@ void registerStorageJoin(StorageFactory & factory)
|
|||||||
{
|
{
|
||||||
const String strictness_str = Poco::toLower(*opt_strictness_id);
|
const String strictness_str = Poco::toLower(*opt_strictness_id);
|
||||||
|
|
||||||
if (strictness_str == "any" || strictness_str == "\'any\'")
|
if (strictness_str == "any")
|
||||||
{
|
{
|
||||||
if (old_any_join)
|
if (old_any_join)
|
||||||
strictness = ASTTableJoin::Strictness::RightAny;
|
strictness = ASTTableJoin::Strictness::RightAny;
|
||||||
else
|
else
|
||||||
strictness = ASTTableJoin::Strictness::Any;
|
strictness = ASTTableJoin::Strictness::Any;
|
||||||
}
|
}
|
||||||
else if (strictness_str == "all" || strictness_str == "\'all\'")
|
else if (strictness_str == "all")
|
||||||
strictness = ASTTableJoin::Strictness::All;
|
strictness = ASTTableJoin::Strictness::All;
|
||||||
else if (strictness_str == "semi" || strictness_str == "\'semi\'")
|
else if (strictness_str == "semi")
|
||||||
strictness = ASTTableJoin::Strictness::Semi;
|
strictness = ASTTableJoin::Strictness::Semi;
|
||||||
else if (strictness_str == "anti" || strictness_str == "\'anti\'")
|
else if (strictness_str == "anti")
|
||||||
strictness = ASTTableJoin::Strictness::Anti;
|
strictness = ASTTableJoin::Strictness::Anti;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strictness == ASTTableJoin::Strictness::Unspecified)
|
if (strictness == ASTTableJoin::Strictness::Unspecified)
|
||||||
throw Exception("First parameter of storage Join must be ANY or ALL or SEMI or ANTI.", ErrorCodes::BAD_ARGUMENTS);
|
throw Exception("First parameter of storage Join must be ANY or ALL or SEMI or ANTI (without quotes).",
|
||||||
|
ErrorCodes::BAD_ARGUMENTS);
|
||||||
|
|
||||||
if (auto opt_kind_id = tryGetIdentifierName(engine_args[1]))
|
if (auto opt_kind_id = tryGetIdentifierName(engine_args[1]))
|
||||||
{
|
{
|
||||||
const String kind_str = Poco::toLower(*opt_kind_id);
|
const String kind_str = Poco::toLower(*opt_kind_id);
|
||||||
|
|
||||||
if (kind_str == "left" || kind_str == "\'left\'")
|
if (kind_str == "left")
|
||||||
kind = ASTTableJoin::Kind::Left;
|
kind = ASTTableJoin::Kind::Left;
|
||||||
else if (kind_str == "inner" || kind_str == "\'inner\'")
|
else if (kind_str == "inner")
|
||||||
kind = ASTTableJoin::Kind::Inner;
|
kind = ASTTableJoin::Kind::Inner;
|
||||||
else if (kind_str == "right" || kind_str == "\'right\'")
|
else if (kind_str == "right")
|
||||||
kind = ASTTableJoin::Kind::Right;
|
kind = ASTTableJoin::Kind::Right;
|
||||||
else if (kind_str == "full" || kind_str == "\'full\'")
|
else if (kind_str == "full")
|
||||||
{
|
{
|
||||||
if (strictness == ASTTableJoin::Strictness::Any)
|
if (strictness == ASTTableJoin::Strictness::Any)
|
||||||
strictness = ASTTableJoin::Strictness::RightAny;
|
strictness = ASTTableJoin::Strictness::RightAny;
|
||||||
@ -177,7 +178,8 @@ void registerStorageJoin(StorageFactory & factory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (kind == ASTTableJoin::Kind::Comma)
|
if (kind == ASTTableJoin::Kind::Comma)
|
||||||
throw Exception("Second parameter of storage Join must be LEFT or INNER or RIGHT or FULL.", ErrorCodes::BAD_ARGUMENTS);
|
throw Exception("Second parameter of storage Join must be LEFT or INNER or RIGHT or FULL (without quotes).",
|
||||||
|
ErrorCodes::BAD_ARGUMENTS);
|
||||||
|
|
||||||
Names key_names;
|
Names key_names;
|
||||||
key_names.reserve(engine_args.size() - 2);
|
key_names.reserve(engine_args.size() - 2);
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
left
|
||||||
|
0 a1
|
||||||
|
1 a2
|
||||||
|
2 a3 b1
|
||||||
|
2 a3 b2
|
||||||
|
3 a4
|
||||||
|
4 a5 b3
|
||||||
|
4 a5 b4
|
||||||
|
4 a5 b5
|
||||||
|
inner
|
||||||
|
2 a3 b1
|
||||||
|
2 a3 b2
|
||||||
|
4 a5 b3
|
||||||
|
4 a5 b4
|
||||||
|
4 a5 b5
|
||||||
|
right
|
||||||
|
2 a3 b1
|
||||||
|
2 a3 b2
|
||||||
|
4 a5 b3
|
||||||
|
4 a5 b4
|
||||||
|
4 a5 b5
|
||||||
|
5 b6
|
||||||
|
full
|
||||||
|
0 a1
|
||||||
|
1 a2
|
||||||
|
2 a3 b1
|
||||||
|
2 a3 b2
|
||||||
|
3 a4
|
||||||
|
4 a5 b3
|
||||||
|
4 a5 b4
|
||||||
|
4 a5 b5
|
||||||
|
5 b6
|
56
dbms/tests/queries/0_stateless/01051_all_join_engine.sql
Normal file
56
dbms/tests/queries/0_stateless/01051_all_join_engine.sql
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
DROP TABLE IF EXISTS t1;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS left_join;
|
||||||
|
DROP TABLE IF EXISTS inner_join;
|
||||||
|
DROP TABLE IF EXISTS right_join;
|
||||||
|
DROP TABLE IF EXISTS full_join;
|
||||||
|
|
||||||
|
CREATE TABLE t1 (x UInt32, str String) engine = Memory;
|
||||||
|
|
||||||
|
CREATE TABLE left_join (x UInt32, s String) engine = Join(ALL, LEFT, x);
|
||||||
|
CREATE TABLE inner_join (x UInt32, s String) engine = Join(ALL, INNER, x);
|
||||||
|
CREATE TABLE right_join (x UInt32, s String) engine = Join(ALL, RIGHT, x);
|
||||||
|
CREATE TABLE full_join (x UInt32, s String) engine = Join(ALL, FULL, x);
|
||||||
|
|
||||||
|
INSERT INTO t1 (x, str) VALUES (0, 'a1'), (1, 'a2'), (2, 'a3'), (3, 'a4'), (4, 'a5');
|
||||||
|
|
||||||
|
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');
|
||||||
|
|
||||||
|
SET join_use_nulls = 0;
|
||||||
|
|
||||||
|
SELECT 'left';
|
||||||
|
SELECT * FROM t1 LEFT JOIN left_join j USING(x) ORDER BY x, str, s;
|
||||||
|
|
||||||
|
SELECT 'inner';
|
||||||
|
SELECT * FROM t1 INNER JOIN inner_join j USING(x) ORDER BY x, str, s;
|
||||||
|
|
||||||
|
SELECT 'right';
|
||||||
|
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;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
DROP TABLE left_join;
|
||||||
|
DROP TABLE inner_join;
|
||||||
|
DROP TABLE right_join;
|
||||||
|
DROP TABLE full_join;
|
@ -16,7 +16,6 @@ any right
|
|||||||
5 b6
|
5 b6
|
||||||
semi left
|
semi left
|
||||||
2 a3 b1
|
2 a3 b1
|
||||||
2 a6 b1
|
|
||||||
4 a5 b3
|
4 a5 b3
|
||||||
semi right
|
semi right
|
||||||
2 a3 b1
|
2 a3 b1
|
||||||
|
@ -45,9 +45,6 @@ SELECT * FROM t1 ANY INNER JOIN any_inner_join j USING(x) ORDER BY x, str, s;
|
|||||||
SELECT 'any right';
|
SELECT 'any right';
|
||||||
SELECT * FROM t1 ANY RIGHT JOIN any_right_join j USING(x) ORDER BY x, str, s;
|
SELECT * FROM t1 ANY RIGHT JOIN any_right_join j USING(x) ORDER BY x, str, s;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO t1 (x, str) VALUES (2, 'a6');
|
|
||||||
|
|
||||||
SELECT 'semi left';
|
SELECT 'semi left';
|
||||||
SELECT * FROM t1 SEMI LEFT JOIN semi_left_join j USING(x) ORDER BY x, str, s;
|
SELECT * FROM t1 SEMI LEFT JOIN semi_left_join j USING(x) ORDER BY x, str, s;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user