mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Enable joined_subquery_requires_alias by default (#9274)
enable joined_subquery_requires_alias by default
This commit is contained in:
parent
2338f16637
commit
912ec60e7e
@ -253,7 +253,7 @@ struct Settings : public SettingsCollection<Settings>
|
||||
M(SettingSeconds, http_receive_timeout, DEFAULT_HTTP_READ_BUFFER_TIMEOUT, "HTTP receive timeout", 0) \
|
||||
M(SettingBool, optimize_throw_if_noop, false, "If setting is enabled and OPTIMIZE query didn't actually assign a merge then an explanatory exception is thrown", 0) \
|
||||
M(SettingBool, use_index_for_in_with_subqueries, true, "Try using an index if there is a subquery or a table expression on the right side of the IN operator.", 0) \
|
||||
M(SettingBool, joined_subquery_requires_alias, false, "Force joined subqueries to have aliases for correct name qualification.", 0) \
|
||||
M(SettingBool, joined_subquery_requires_alias, true, "Force joined subqueries and table functions to have aliases for correct name qualification.", 0) \
|
||||
M(SettingBool, empty_result_for_aggregation_by_empty_set, false, "Return empty result when aggregating without keys on empty set.", 0) \
|
||||
M(SettingBool, allow_distributed_ddl, true, "If it is set to true, then a user is allowed to executed distributed DDL queries.", 0) \
|
||||
M(SettingUInt64, odbc_max_field_size, 1024, "Max size of filed can be read from ODBC dictionary. Long strings are truncated.", 0) \
|
||||
|
@ -111,7 +111,7 @@ std::vector<TableWithColumnNames> getTablesWithColumns(const std::vector<const A
|
||||
{
|
||||
for (auto & pr : tables_with_columns)
|
||||
if (pr.table.table.empty() && pr.table.alias.empty())
|
||||
throw Exception("Not unique subquery in FROM requires an alias (or joined_subquery_requires_alias=0 to disable restriction).",
|
||||
throw Exception("No alias for subquery or table function in JOIN (set joined_subquery_requires_alias=0 to disable restriction).",
|
||||
ErrorCodes::ALIAS_REQUIRED);
|
||||
}
|
||||
|
||||
|
@ -88,14 +88,14 @@ SELECT PN, PVq, PVt FROM
|
||||
ARRAY JOIN ProfileEvents.Names AS PN, ProfileEvents.Values AS PV
|
||||
WHERE event_date >= today()-1 AND query_id='$query_id'
|
||||
GROUP BY PN
|
||||
)
|
||||
) js1
|
||||
ANY INNER JOIN
|
||||
(
|
||||
SELECT PN, PV AS PVq
|
||||
FROM system.query_log
|
||||
ARRAY JOIN ProfileEvents.Names AS PN, ProfileEvents.Values AS PV
|
||||
WHERE event_date >= today()-1 AND query_id='$query_id'
|
||||
)
|
||||
) js2
|
||||
USING PN
|
||||
WHERE
|
||||
NOT PN IN ('ContextLock') AND
|
||||
|
@ -18,12 +18,12 @@ ${CLICKHOUSE_CLIENT} --query="SELECT * FROM input_function_table_2 FORMAT CSV"
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS input_function_table_3"
|
||||
${CLICKHOUSE_CLIENT} --query="CREATE TABLE input_function_table_3 (a String, b Date, c Int32, d Int16) ENGINE=Memory()"
|
||||
cat ${CLICKHOUSE_TMP}/data_for_input_function.csv | ${CLICKHOUSE_CLIENT} --query="INSERT INTO input_function_table_3 (a, b, c) SELECT * FROM (SELECT s, b, c*c FROM input('s String, b Int32, c Int32') JOIN input_function_table_1 ON s=input_function_table_1.a) FORMAT CSV"
|
||||
cat ${CLICKHOUSE_TMP}/data_for_input_function.csv | ${CLICKHOUSE_CLIENT} --query="INSERT INTO input_function_table_3 (a, b, c) SELECT * FROM (SELECT s, b, c*c FROM input('s String, b Int32, c Int32') js1 JOIN input_function_table_1 ON s=input_function_table_1.a) FORMAT CSV"
|
||||
${CLICKHOUSE_CLIENT} --query="SELECT * FROM input_function_table_3 FORMAT CSV"
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS input_function_table_4"
|
||||
${CLICKHOUSE_CLIENT} --query="CREATE TABLE input_function_table_4 (a String, b Date, c Int32, d Int16) ENGINE=Memory()"
|
||||
cat ${CLICKHOUSE_TMP}/data_for_input_function.csv | ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}&query=INSERT%20INTO%20input_function_table_4%20%28a%2C%20b%2C%20c%29%20SELECT%20%2A%20FROM%20%28SELECT%20s%2C%20b%2C%20c%2Ac%20FROM%20input%28%27s%20String%2C%20b%20Int32%2C%20c%20Int32%27%29%20JOIN%20input_function_table_1%20ON%20s%3Dinput_function_table_1.a%29%20FORMAT%20CSV" --data-binary @-
|
||||
cat ${CLICKHOUSE_TMP}/data_for_input_function.csv | ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}&query=INSERT%20INTO%20input_function_table_4%20%28a%2C%20b%2C%20c%29%20SELECT%20%2A%20FROM%20%28SELECT%20s%2C%20b%2C%20c%2Ac%20FROM%20input%28%27s%20String%2C%20b%20Int32%2C%20c%20Int32%27%29%20js1%20JOIN%20input_function_table_1%20ON%20s%3Dinput_function_table_1.a%29%20FORMAT%20CSV" --data-binary @-
|
||||
${CLICKHOUSE_CLIENT} --query="SELECT * FROM input_function_table_4 FORMAT CSV"
|
||||
|
||||
|
||||
|
@ -7,8 +7,8 @@ insert into test_join values ('2019-01-01', 2, 'b');
|
||||
insert into test_join values ('2019-01-01', 3, 'c');
|
||||
insert into test_join values ('2019-01-01', 1, null);
|
||||
|
||||
SELECT id, date, name FROM (SELECT id, date, name FROM test_join GROUP BY id, name, date)
|
||||
FULL OUTER JOIN (SELECT id, date, name FROM test_join GROUP BY id, name, date)
|
||||
SELECT id, date, name FROM (SELECT id, date, name FROM test_join GROUP BY id, name, date) js1
|
||||
FULL OUTER JOIN (SELECT id, date, name FROM test_join GROUP BY id, name, date) js2
|
||||
USING (id, name, date)
|
||||
ORDER BY id, name;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
0 ['left'] 0 ['left'] \N
|
||||
1 ['left'] 1 ['left'] 1
|
||||
2 [] \N [] 2
|
||||
['left'] 0 ['left'] \N
|
||||
['left'] 1 ['left'] 1
|
||||
[] \N [] 2
|
||||
0 ['left'] 0 [] \N
|
||||
1 ['left'] 1 ['right'] 1
|
||||
2 [] \N ['right'] 2
|
||||
['left'] 0 [] \N
|
||||
['left'] 1 ['right'] 1
|
||||
[] \N ['right'] 2
|
||||
['left'] 42 \N
|
||||
['right'] \N 42
|
||||
|
@ -3,32 +3,32 @@ SET join_use_nulls = 1;
|
||||
SELECT * FROM
|
||||
(
|
||||
SELECT number, ['left'] as ar, number AS left_number FROM system.numbers LIMIT 2
|
||||
)
|
||||
) js1
|
||||
FULL JOIN
|
||||
(
|
||||
SELECT number, ['right'] as ar, number AS right_number FROM system.numbers LIMIT 1, 2
|
||||
)
|
||||
) js2
|
||||
USING (number)
|
||||
ORDER BY number;
|
||||
|
||||
SELECT * FROM
|
||||
(
|
||||
SELECT ['left'] as ar, number AS left_number FROM system.numbers LIMIT 2
|
||||
)
|
||||
) js1
|
||||
FULL JOIN
|
||||
(
|
||||
SELECT ['right'] as ar, number AS right_number FROM system.numbers LIMIT 1, 2
|
||||
)
|
||||
) js2
|
||||
ON left_number = right_number
|
||||
ORDER BY left_number;
|
||||
|
||||
SELECT * FROM
|
||||
(
|
||||
SELECT ['left'] as ar, 42 AS left_number
|
||||
)
|
||||
) js1
|
||||
FULL JOIN
|
||||
(
|
||||
SELECT ['right'] as ar, 42 AS right_number
|
||||
)
|
||||
) js2
|
||||
USING(ar)
|
||||
ORDER BY left_number;
|
||||
|
@ -5,7 +5,7 @@ DROP TABLE IF EXISTS view_foo_bar;
|
||||
create table foo (ddate Date, id Int64, n String) ENGINE = ReplacingMergeTree(ddate, (id), 8192);
|
||||
create table bar (ddate Date, id Int64, n String, foo_id Int64) ENGINE = ReplacingMergeTree(ddate, (id), 8192);
|
||||
insert into bar (id, n, foo_id) values (1, 'bar_n_1', 1);
|
||||
create MATERIALIZED view view_foo_bar ENGINE = ReplacingMergeTree(ddate, (bar_id), 8192) as select ddate, bar_id, bar_n, foo_id, foo_n from (select ddate, id as bar_id, n as bar_n, foo_id from bar) any left join (select id as foo_id, n as foo_n from foo) using foo_id;
|
||||
create MATERIALIZED view view_foo_bar ENGINE = ReplacingMergeTree(ddate, (bar_id), 8192) as select ddate, bar_id, bar_n, foo_id, foo_n from (select ddate, id as bar_id, n as bar_n, foo_id from bar) js1 any left join (select id as foo_id, n as foo_n from foo) js2 using foo_id;
|
||||
insert into bar (id, n, foo_id) values (1, 'bar_n_1', 1);
|
||||
SELECT * FROM view_foo_bar;
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
drop table if exists tab;
|
||||
create table tab (x UInt64) engine = MergeTree order by tuple();
|
||||
|
||||
insert into tab select number as n from numbers(20) semi left join (select number * 10 as n from numbers(2)) using(n) settings max_block_size = 5;
|
||||
insert into tab select number as n from numbers(20) nums
|
||||
semi left join (select number * 10 as n from numbers(2)) js2 using(n)
|
||||
settings max_block_size = 5;
|
||||
select * from tab order by x;
|
||||
|
||||
drop table tab;
|
||||
|
@ -1,6 +1,6 @@
|
||||
SET join_algorithm = 'hash';
|
||||
|
||||
SELECT number as n, j FROM numbers(4)
|
||||
SELECT number as n, j FROM numbers(4) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number + 10 AS j
|
||||
FROM numbers(4000)
|
||||
@ -9,7 +9,7 @@ USING n;
|
||||
|
||||
SET max_rows_in_join = 1000;
|
||||
|
||||
SELECT number as n, j FROM numbers(4)
|
||||
SELECT number as n, j FROM numbers(4) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number + 10 AS j
|
||||
FROM numbers(4000)
|
||||
@ -18,7 +18,7 @@ USING n; -- { serverError 191 }
|
||||
|
||||
SET join_algorithm = 'partial_merge';
|
||||
|
||||
SELECT number as n, j FROM numbers(4)
|
||||
SELECT number as n, j FROM numbers(4) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number + 10 AS j
|
||||
FROM numbers(4000)
|
||||
@ -27,7 +27,7 @@ USING n;
|
||||
|
||||
SET partial_merge_join_optimizations = 1;
|
||||
|
||||
SELECT number as n, j FROM numbers(4)
|
||||
SELECT number as n, j FROM numbers(4) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number + 10 AS j
|
||||
FROM numbers(4000)
|
||||
@ -36,7 +36,7 @@ USING n;
|
||||
|
||||
SET join_algorithm = 'auto';
|
||||
|
||||
SELECT number as n, j FROM numbers(4)
|
||||
SELECT number as n, j FROM numbers(4) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number + 10 AS j
|
||||
FROM numbers(4000)
|
||||
|
@ -1,6 +1,6 @@
|
||||
SET max_memory_usage = 32000000;
|
||||
|
||||
SELECT number * 200000 as n, j FROM numbers(5)
|
||||
SELECT number * 200000 as n, j FROM numbers(5) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number AS j
|
||||
FROM numbers(1000000)
|
||||
@ -10,14 +10,14 @@ USING n; -- { serverError 241 }
|
||||
SET partial_merge_join = 1;
|
||||
SET default_max_bytes_in_join = 0;
|
||||
|
||||
SELECT number * 200000 as n, j FROM numbers(5)
|
||||
SELECT number * 200000 as n, j FROM numbers(5) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number AS j
|
||||
FROM numbers(1000000)
|
||||
) js2
|
||||
USING n; -- { serverError 12 }
|
||||
|
||||
SELECT number * 200000 as n, j FROM numbers(5)
|
||||
SELECT number * 200000 as n, j FROM numbers(5) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number AS j
|
||||
FROM numbers(1000000)
|
||||
@ -25,7 +25,7 @@ ANY LEFT JOIN (
|
||||
USING n
|
||||
SETTINGS max_bytes_in_join = 30000000; -- { serverError 241 }
|
||||
|
||||
SELECT number * 200000 as n, j FROM numbers(5)
|
||||
SELECT number * 200000 as n, j FROM numbers(5) nums
|
||||
ANY LEFT JOIN (
|
||||
SELECT number * 2 AS n, number AS j
|
||||
FROM numbers(1000000)
|
||||
@ -36,7 +36,7 @@ SETTINGS max_bytes_in_join = 10000000;
|
||||
|
||||
SET partial_merge_join_optimizations = 1;
|
||||
|
||||
SELECT number * 200000 as n, j FROM numbers(5)
|
||||
SELECT number * 200000 as n, j FROM numbers(5) nums
|
||||
LEFT JOIN (
|
||||
SELECT number * 2 AS n, number AS j
|
||||
FROM numbers(1000000)
|
||||
@ -47,7 +47,7 @@ SETTINGS max_rows_in_join = 100000;
|
||||
|
||||
SET default_max_bytes_in_join = 10000000;
|
||||
|
||||
SELECT number * 200000 as n, j FROM numbers(5)
|
||||
SELECT number * 200000 as n, j FROM numbers(5) nums
|
||||
JOIN (
|
||||
SELECT number * 2 AS n, number AS j
|
||||
FROM numbers(1000000)
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
|
||||
SELECT 'IN empty set',count() FROM system.numbers WHERE number IN (SELECT toUInt64(1) WHERE 0);
|
||||
SELECT 'IN non-empty set',count() FROM (SELECT number FROM system.numbers LIMIT 10) t1 WHERE t1.number IN (SELECT toUInt64(1) WHERE 1);
|
||||
SELECT 'NOT IN empty set',count() FROM (SELECT number FROM system.numbers LIMIT 10) WHERE number NOT IN (SELECT toUInt64(1) WHERE 0);
|
||||
|
@ -5,7 +5,7 @@ DROP TABLE IF EXISTS t_d;
|
||||
DROP TABLE IF EXISTS t_v;
|
||||
CREATE TABLE t (`A` Int64) ENGINE = MergeTree() ORDER BY tuple();
|
||||
CREATE TABLE t_d AS t ENGINE = Distributed(test_shard_localhost, currentDatabase(), t);
|
||||
CREATE MATERIALIZED VIEW t_v ENGINE = MergeTree() ORDER BY tuple() AS SELECT A FROM t LEFT JOIN ( SELECT toInt64(dummy) AS A FROM system.one ) USING (A);
|
||||
CREATE MATERIALIZED VIEW t_v ENGINE = MergeTree() ORDER BY tuple() AS SELECT A FROM t LEFT JOIN ( SELECT toInt64(dummy) AS A FROM system.one ) js2 USING (A);
|
||||
|
||||
INSERT INTO t_d SELECT number FROM numbers(2);
|
||||
SELECT * FROM t_v ORDER BY A;
|
||||
|
@ -7,13 +7,13 @@ CREATE TABLE Beta (foo LowCardinality(String), baz UInt64) ENGINE = Memory;
|
||||
INSERT INTO Alpha VALUES ('a', 1);
|
||||
INSERT INTO Beta VALUES ('a', 2), ('b', 3);
|
||||
|
||||
SELECT * FROM Alpha FULL JOIN (SELECT 'b' as foo) USING (foo) ORDER BY foo;
|
||||
SELECT * FROM Alpha FULL JOIN (SELECT 'b' as foo) js2 USING (foo) ORDER BY foo;
|
||||
SELECT * FROM Alpha FULL JOIN Beta USING (foo) ORDER BY foo;
|
||||
SELECT * FROM Alpha FULL JOIN Beta ON Alpha.foo = Beta.foo ORDER BY foo;
|
||||
|
||||
SET join_use_nulls = 1;
|
||||
|
||||
SELECT * FROM Alpha FULL JOIN (SELECT 'b' as foo) USING (foo) ORDER BY foo;
|
||||
SELECT * FROM Alpha FULL JOIN (SELECT 'b' as foo) js2 USING (foo) ORDER BY foo;
|
||||
SELECT * FROM Alpha FULL JOIN Beta USING (foo) ORDER BY foo;
|
||||
SELECT * FROM Alpha FULL JOIN Beta ON Alpha.foo = Beta.foo ORDER BY foo;
|
||||
|
||||
|
@ -7,9 +7,9 @@ CREATE TABLE testJoinTable (number UInt64, data String) ENGINE = Join(ANY, INNER
|
||||
|
||||
INSERT INTO testJoinTable VALUES (1, '1'), (2, '2'), (3, '3');
|
||||
|
||||
SELECT * FROM (SELECT * FROM numbers(10)) INNER JOIN testJoinTable USING number; -- { serverError 264 }
|
||||
SELECT * FROM (SELECT * FROM numbers(10)) INNER JOIN (SELECT * FROM testJoinTable) USING number;
|
||||
SELECT * FROM (SELECT * FROM numbers(10)) ANY INNER JOIN testJoinTable USING number;
|
||||
SELECT * FROM (SELECT * FROM numbers(10)) js1 INNER JOIN testJoinTable USING number; -- { serverError 264 }
|
||||
SELECT * FROM (SELECT * FROM numbers(10)) js1 INNER JOIN (SELECT * FROM testJoinTable) js2 USING number;
|
||||
SELECT * FROM (SELECT * FROM numbers(10)) js1 ANY INNER JOIN testJoinTable USING number;
|
||||
SELECT * FROM testJoinTable;
|
||||
|
||||
DROP TABLE testJoinTable;
|
||||
|
@ -11,9 +11,9 @@ INSERT INTO a VALUES (1,1,1)(2,2,2)(3,3,3);
|
||||
INSERT INTO id1 VALUES (1,1)(2,2)(3,3);
|
||||
INSERT INTO id2 VALUES (1,1)(2,2)(3,3);
|
||||
|
||||
SELECT * from (SELECT * FROM a ANY LEFT OUTER JOIN id1 USING id1) ANY LEFT OUTER JOIN id2 USING id2;
|
||||
SELECT * from (SELECT * FROM a ANY LEFT OUTER JOIN id1 USING id1) js1 ANY LEFT OUTER JOIN id2 USING id2;
|
||||
|
||||
create view b as (SELECT * from (SELECT * FROM a ANY LEFT OUTER JOIN id1 USING id1) ANY LEFT OUTER JOIN id2 USING id2);
|
||||
create view b as (SELECT * from (SELECT * FROM a ANY LEFT OUTER JOIN id1 USING id1) js1 ANY LEFT OUTER JOIN id2 USING id2);
|
||||
SELECT '-';
|
||||
SELECT * FROM b;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
SET enable_debug_queries = 1;
|
||||
SET enable_optimize_predicate_expression = 1;
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
|
||||
-- https://github.com/ClickHouse/ClickHouse/issues/3885
|
||||
-- https://github.com/ClickHouse/ClickHouse/issues/5485
|
||||
|
@ -4,17 +4,17 @@ SET partial_merge_join = 1;
|
||||
SELECT 'defaults';
|
||||
|
||||
SELECT count(1) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(10)
|
||||
SELECT materialize(1) as k, n FROM numbers(10) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(1000000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(1000)
|
||||
SELECT materialize(1) as k, n FROM numbers(1000) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(10000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(n) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(1000000)
|
||||
SELECT materialize(1) as k, n FROM numbers(1000000) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(10)) j
|
||||
USING k);
|
||||
|
||||
@ -22,12 +22,12 @@ SELECT count(1), uniqExact(n) FROM (
|
||||
SET max_joined_block_size_rows = 0;
|
||||
|
||||
SELECT count(1) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(10)
|
||||
SELECT materialize(1) as k, n FROM numbers(10) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(1000000)) j
|
||||
USING k); -- { serverError 241 }
|
||||
|
||||
SELECT count(1) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(1000)
|
||||
SELECT materialize(1) as k, n FROM numbers(1000) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(10000)) j
|
||||
USING k); -- { serverError 241 }
|
||||
|
||||
@ -35,17 +35,17 @@ SELECT 'max_joined_block_size_rows = 2000';
|
||||
SET max_joined_block_size_rows = 2000;
|
||||
|
||||
SELECT count(1) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(10)
|
||||
SELECT materialize(1) as k, n FROM numbers(10) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(1000000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(n) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(1000)
|
||||
SELECT materialize(1) as k, n FROM numbers(1000) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(10000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(n) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(1000000)
|
||||
SELECT materialize(1) as k, n FROM numbers(1000000) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(10)) j
|
||||
USING k);
|
||||
|
||||
@ -53,16 +53,16 @@ SELECT 'max_rows_in_join = 1000';
|
||||
SET max_rows_in_join = 1000;
|
||||
|
||||
SELECT count(1) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(10)
|
||||
SELECT materialize(1) as k, n FROM numbers(10) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(1000000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(n) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(1000)
|
||||
SELECT materialize(1) as k, n FROM numbers(1000) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(10000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(n) FROM (
|
||||
SELECT materialize(1) as k, n FROM numbers(1000000)
|
||||
SELECT materialize(1) as k, n FROM numbers(1000000) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(10)) j
|
||||
USING k);
|
||||
|
@ -6,7 +6,7 @@ FROM mt
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT 1 AS x
|
||||
) USING (x)
|
||||
) js2 USING (x)
|
||||
PREWHERE x IN (1) WHERE y = today();
|
||||
|
||||
DROP TABLE mt;
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
|
||||
SYSTEM STOP MERGES;
|
||||
|
||||
-- incremental streaming usecase
|
||||
|
@ -1,87 +1,87 @@
|
||||
SET partial_merge_join = 1;
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(1) as k FROM numbers(1)
|
||||
SELECT materialize(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(1) as k FROM numbers(1)
|
||||
SELECT materialize(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT 1 AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT 1 as k FROM numbers(1)
|
||||
SELECT 1 as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT 1 as k FROM numbers(1)
|
||||
SELECT 1 as k FROM numbers(1) nums
|
||||
JOIN (SELECT 1 AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT 'first nullable';
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1)
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1)
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1) nums
|
||||
JOIN (SELECT 1 AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT toNullable(1) as k FROM numbers(1)
|
||||
SELECT toNullable(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT toNullable(1) as k FROM numbers(1)
|
||||
SELECT toNullable(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT 1 AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT 'second nullable';
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(1) as k FROM numbers(1)
|
||||
SELECT materialize(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(toNullable(1)) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(1) as k FROM numbers(1)
|
||||
SELECT materialize(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT toNullable(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT 1 as k FROM numbers(1)
|
||||
SELECT 1 as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(toNullable(1)) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT 1 as k FROM numbers(1)
|
||||
SELECT 1 as k FROM numbers(1) nums
|
||||
JOIN (SELECT toNullable(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT 'both nullable';
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1)
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(toNullable(1)) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1)
|
||||
SELECT materialize(toNullable(1)) as k FROM numbers(1) nums
|
||||
JOIN (SELECT toNullable(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT toNullable(1) as k FROM numbers(1)
|
||||
SELECT toNullable(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT materialize(toNullable(1)) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
||||
SELECT count(1), uniqExact(1) FROM (
|
||||
SELECT toNullable(1) as k FROM numbers(1)
|
||||
SELECT toNullable(1) as k FROM numbers(1) nums
|
||||
JOIN (SELECT toNullable(1) AS k, number n FROM numbers(100000)) j
|
||||
USING k);
|
||||
|
@ -6,7 +6,7 @@ FROM
|
||||
SELECT NULL
|
||||
UNION ALL
|
||||
SELECT NULL
|
||||
)
|
||||
) js1
|
||||
ALL FULL OUTER JOIN
|
||||
(
|
||||
SELECT 1 AS id
|
||||
@ -14,7 +14,7 @@ ALL FULL OUTER JOIN
|
||||
SELECT NULL
|
||||
UNION ALL
|
||||
SELECT NULL
|
||||
) USING (id)
|
||||
) js2 USING (id)
|
||||
ORDER BY id;
|
||||
|
||||
SELECT '---';
|
||||
@ -23,11 +23,11 @@ SELECT *
|
||||
FROM
|
||||
(
|
||||
SELECT NULL AS x
|
||||
)
|
||||
) js1
|
||||
INNER JOIN
|
||||
(
|
||||
SELECT NULL AS x
|
||||
) USING (x);
|
||||
) js2 USING (x);
|
||||
|
||||
SELECT '---';
|
||||
|
||||
@ -35,8 +35,8 @@ SELECT *
|
||||
FROM
|
||||
(
|
||||
SELECT NULL AS x
|
||||
)
|
||||
) js1
|
||||
FULL OUTER JOIN
|
||||
(
|
||||
SELECT NULL AS x
|
||||
) USING (x);
|
||||
) js2 USING (x);
|
||||
|
@ -2,7 +2,7 @@ drop table if exists test_01081;
|
||||
|
||||
create table test_01081 (key Int) engine=MergeTree() order by key;
|
||||
insert into test_01081 select * from system.numbers limit 10;
|
||||
select 1 from remote('127.{1,2}', currentDatabase(), test_01081) join system.one as rhs on rhs.dummy = 1 order by 1;
|
||||
select 1 from remote('127.{1,2}', currentDatabase(), test_01081) lhs join system.one as rhs on rhs.dummy = 1 order by 1;
|
||||
|
||||
-- With multiple blocks triggers:
|
||||
--
|
||||
@ -13,6 +13,6 @@ select 1 from remote('127.{1,2}', currentDatabase(), test_01081) join system.one
|
||||
-- With experimental_use_processors=1 (default at the time of writing).
|
||||
|
||||
insert into test_01081 select * from system.numbers limit 10;
|
||||
select 1 from remote('127.{1,2}', currentDatabase(), test_01081) join system.one as rhs on rhs.dummy = 1 order by 1;
|
||||
select 1 from remote('127.{1,2}', currentDatabase(), test_01081) lhs join system.one as rhs on rhs.dummy = 1 order by 1;
|
||||
|
||||
drop table if exists test_01081;
|
||||
|
Loading…
Reference in New Issue
Block a user