add negative test for partial_merge_join variants

This commit is contained in:
chertus 2020-02-21 16:16:59 +03:00
parent aeefb78157
commit 759d137162
3 changed files with 76 additions and 1 deletions

View File

@ -461,7 +461,17 @@ MergeJoin::MergeJoin(std::shared_ptr<AnalyzedJoin> 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);

View File

@ -0,0 +1,6 @@
all
cross
any
semi
anti
asof

View File

@ -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;