mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
basic support for multiple_joins_emulation CLICKHOUSE-3996
This commit is contained in:
parent
600755745b
commit
e8245f5935
@ -296,6 +296,7 @@ struct Settings
|
||||
M(SettingBool, enable_debug_queries, false, "Enables debug queries such as AST.") \
|
||||
M(SettingBool, enable_unaligned_array_join, false, "Allow ARRAY JOIN with multiple arrays that have different sizes. When this settings is enabled, arrays will be resized to the longest one.") \
|
||||
M(SettingBool, low_cardinality_allow_in_native_format, true, "Use LowCardinality type in Native format. Otherwise, convert LowCardinality columns to ordinary for select query, and convert ordinary columns to required LowCardinality for insert query.") \
|
||||
M(SettingBool, allow_experimental_multiple_joins_emulation, false, "Emulate multiple joins using subselects") \
|
||||
|
||||
#define DECLARE(TYPE, NAME, DEFAULT, DESCRIPTION) \
|
||||
TYPE NAME {DEFAULT};
|
||||
|
@ -188,12 +188,13 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
||||
if (!internal)
|
||||
logQuery(query.substr(0, settings.log_queries_cut_to_length), context);
|
||||
|
||||
#if 1
|
||||
JoinToSubqueryTransformVisitor::Data join_to_subs_data;
|
||||
JoinToSubqueryTransformVisitor(join_to_subs_data).visit(ast);
|
||||
if (join_to_subs_data.done)
|
||||
logQuery(queryToString(*ast), context);
|
||||
#endif
|
||||
if (settings.allow_experimental_multiple_joins_emulation)
|
||||
{
|
||||
JoinToSubqueryTransformVisitor::Data join_to_subs_data;
|
||||
JoinToSubqueryTransformVisitor(join_to_subs_data).visit(ast);
|
||||
if (join_to_subs_data.done)
|
||||
logQuery(queryToString(*ast), context);
|
||||
}
|
||||
|
||||
/// Check the limits.
|
||||
checkASTSizeLimits(*ast, settings);
|
||||
|
@ -0,0 +1,7 @@
|
||||
0 0 0
|
||||
6 60 600
|
||||
12 120 1200
|
||||
18 180 1800
|
||||
0 0 0
|
||||
10 100 1000
|
||||
20 200 2000
|
32
dbms/tests/queries/0_stateless/00820_multiple_joins.sql
Normal file
32
dbms/tests/queries/0_stateless/00820_multiple_joins.sql
Normal file
@ -0,0 +1,32 @@
|
||||
USE test;
|
||||
|
||||
DROP TABLE IF EXISTS table1;
|
||||
DROP TABLE IF EXISTS table2;
|
||||
DROP TABLE IF EXISTS table3;
|
||||
DROP TABLE IF EXISTS table5;
|
||||
|
||||
CREATE TABLE table1 (a UInt32) ENGINE = Memory;
|
||||
CREATE TABLE table2 (a UInt32, b UInt32) ENGINE = Memory;
|
||||
CREATE TABLE table3 (b UInt32, c UInt32) ENGINE = Memory;
|
||||
CREATE TABLE table5 (a UInt32, b UInt32, c UInt32) ENGINE = Memory;
|
||||
|
||||
INSERT INTO table1 SELECT number FROM numbers(21);
|
||||
INSERT INTO table2 SELECT number * 2, number * 20 FROM numbers(11);
|
||||
INSERT INTO table3 SELECT number * 30, number * 300 FROM numbers(10);
|
||||
INSERT INTO table5 SELECT number * 5, number * 50, number * 500 FROM numbers(10);
|
||||
|
||||
SET allow_experimental_multiple_joins_emulation = 1;
|
||||
|
||||
-- FIXME: wrong names qualification
|
||||
select a, b, c from table1 as t1 join table2 as t2 on t1.a = t2.a join table3 as t3 on b = t3.b;
|
||||
select a, b, c from table1 as t1 join table2 as t2 on t1.a = t2.a join table5 as t5 on a = t5.a AND b = t5.b;
|
||||
--select a, b, c, d from table1 as t1 join table2 as t2 on t1.a = t2.a join table3 as t3 on b = t3.b join table5 as t5 on c = t5.c;
|
||||
|
||||
--select t1.x, t2.y, t3.z from table1 as t1 join table2 as t2 on t1.x = t2.x join table3 as t3 on t2.y = t3.y;
|
||||
--select t1.x, t2.y, t3.z from table1 as t1 join (select * from table2 as t2 join table3 as t3 on t2.y = t3.y) on t1.x = t2.x;
|
||||
--select t1.x, j1.y, j1.z from table1 as t1 join (select * from table2 as t2 join table3 as t3 on t2.y = t3.y) as j1 on t1.x = j1.x;
|
||||
|
||||
DROP TABLE table1;
|
||||
DROP TABLE table2;
|
||||
DROP TABLE table3;
|
||||
DROP TABLE table5;
|
Loading…
Reference in New Issue
Block a user