From 759d1371621fe76705db104385be12759a1faa16 Mon Sep 17 00:00:00 2001 From: chertus Date: Fri, 21 Feb 2020 16:16:59 +0300 Subject: [PATCH] add negative test for partial_merge_join variants --- dbms/src/Interpreters/MergeJoin.cpp | 12 +++- ...1010_partial_merge_join_negative.reference | 6 ++ .../01010_partial_merge_join_negative.sql | 59 +++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.reference create mode 100644 dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.sql diff --git a/dbms/src/Interpreters/MergeJoin.cpp b/dbms/src/Interpreters/MergeJoin.cpp index 2538863db85..27b7d87b8ca 100644 --- a/dbms/src/Interpreters/MergeJoin.cpp +++ b/dbms/src/Interpreters/MergeJoin.cpp @@ -461,7 +461,17 @@ MergeJoin::MergeJoin(std::shared_ptr table_join_, const Block & ri , max_rows_in_right_block(table_join->maxRowsInRightBlock()) { if (!isLeft(table_join->kind()) && !isInner(table_join->kind())) - throw Exception("Partial merge supported for LEFT and INNER JOINs only", ErrorCodes::NOT_IMPLEMENTED); + throw Exception("Not supported. PartialMergeJoin supports LEFT and INNER JOINs kinds.", ErrorCodes::NOT_IMPLEMENTED); + + switch (table_join->strictness()) + { + case ASTTableJoin::Strictness::Any: + case ASTTableJoin::Strictness::All: + case ASTTableJoin::Strictness::Semi: + break; + default: + throw Exception("Not supported. PartialMergeJoin supports ALL, ANY and SEMI JOINs variants.", ErrorCodes::NOT_IMPLEMENTED); + } if (!max_rows_in_right_block) throw Exception("partial_merge_join_rows_in_right_blocks cannot be zero", ErrorCodes::PARAMETER_OUT_OF_BOUND); diff --git a/dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.reference b/dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.reference new file mode 100644 index 00000000000..26049d060cc --- /dev/null +++ b/dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.reference @@ -0,0 +1,6 @@ +all +cross +any +semi +anti +asof diff --git a/dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.sql b/dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.sql new file mode 100644 index 00000000000..f50ae387047 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01010_partial_merge_join_negative.sql @@ -0,0 +1,59 @@ +DROP TABLE IF EXISTS t0; +DROP TABLE IF EXISTS t1; + +CREATE TABLE t0 (x UInt32, y UInt64) engine = MergeTree ORDER BY (x,y); +CREATE TABLE t1 (x UInt32, y UInt64) engine = MergeTree ORDER BY (x,y); + +SET join_algorithm = 'partial_merge'; + +SELECT 'all'; + +SELECT * FROM t0 ANY LEFT JOIN t1 ON t1.x = t0.x; +SELECT * FROM t0 ANY INNER JOIN t1 ON t1.x = t0.x; +SELECT * FROM t0 ANY RIGHT JOIN t1 ON t1.x = t0.x; -- { serverError 48 } +SELECT * FROM t0 ANY FULL JOIN t1 ON t1.x = t0.x; -- { serverError 48 } + +SELECT * FROM t0 LEFT JOIN t1 ON t1.x = t0.x; +SELECT * FROM t0 INNER JOIN t1 ON t1.x = t0.x; +SELECT * FROM t0 RIGHT JOIN t1 ON t1.x = t0.x; -- { serverError 48 } +SELECT * FROM t0 FULL JOIN t1 ON t1.x = t0.x; -- { serverError 48 } + +SELECT 'cross'; + +SELECT * FROM t0 CROSS JOIN t1; -- { serverError 48 } + +SELECT 'any'; + +SELECT * FROM t0 ANY LEFT JOIN t1 USING (x); +SELECT * FROM t0 ANY INNER JOIN t1 USING (x); +SELECT * FROM t0 ANY RIGHT JOIN t1 USING (x); -- { serverError 48 } +SELECT * FROM t0 ANY FULL JOIN t1 USING (x); -- { serverError 48 } + +SELECT * FROM t0 LEFT JOIN t1 USING (x); +SELECT * FROM t0 INNER JOIN t1 USING (x); +SELECT * FROM t0 RIGHT JOIN t1 USING (x); -- { serverError 48 } +SELECT * FROM t0 FULL JOIN t1 USING (x); -- { serverError 48 } + +SELECT 'semi'; + +SELECT * FROM t0 SEMI LEFT JOIN t1 ON t1.x = t0.x; +SELECT * FROM t0 SEMI RIGHT JOIN t1 ON t1.x = t0.x; -- { serverError 48 } + +SELECT * FROM t0 SEMI LEFT JOIN t1 USING (x); +SELECT * FROM t0 SEMI RIGHT JOIN t1 USING (x); -- { serverError 48 } + +SELECT 'anti'; + +SELECT * FROM t0 ANTI LEFT JOIN t1 ON t1.x = t0.x; -- { serverError 48 } +SELECT * FROM t0 ANTI RIGHT JOIN t1 ON t1.x = t0.x; -- { serverError 48 } + +SELECT * FROM t0 ANTI LEFT JOIN t1 USING (x); -- { serverError 48 } +SELECT * FROM t0 ANTI RIGHT JOIN t1 USING (x); -- { serverError 48 } + +SELECT 'asof'; + +SELECT * FROM t0 ASOF LEFT JOIN t1 ON t1.x = t0.x AND t0.y > t1.y; -- { serverError 48 } +SELECT * FROM t0 ASOF LEFT JOIN t1 USING (x, y); -- { serverError 48 } + +DROP TABLE t0; +DROP TABLE t1;