diff --git a/dbms/src/Core/Settings.h b/dbms/src/Core/Settings.h index aa6893d6d85..b5a75f7dc4b 100644 --- a/dbms/src/Core/Settings.h +++ b/dbms/src/Core/Settings.h @@ -220,6 +220,7 @@ struct Settings : public SettingsCollection M(SettingSeconds, http_receive_timeout, DEFAULT_HTTP_READ_BUFFER_TIMEOUT, "HTTP receive timeout") \ 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") \ 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.") \ + M(SettingBool, subquery_requires_alias, false, "Force subquery in FROM to have an alias for correct name qualification.") \ M(SettingBool, empty_result_for_aggregation_by_empty_set, false, "Return empty result when aggregating without keys on empty set.") \ M(SettingBool, allow_distributed_ddl, true, "If it is set to true, then a user is allowed to executed distributed DDL queries.") \ M(SettingUInt64, odbc_max_field_size, 1024, "Max size of filed can be read from ODBC dictionary. Long strings are truncated.") \ diff --git a/dbms/src/Interpreters/JoinToSubqueryTransformVisitor.cpp b/dbms/src/Interpreters/JoinToSubqueryTransformVisitor.cpp index 67e6bc9855b..1b81d181db1 100644 --- a/dbms/src/Interpreters/JoinToSubqueryTransformVisitor.cpp +++ b/dbms/src/Interpreters/JoinToSubqueryTransformVisitor.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -295,6 +296,23 @@ struct RewriteTablesVisitorData } }; +/// Attach alias to the first visited subquery +struct SetSubqueryAliasVisitorData +{ + using TypeToVisit = ASTSubquery; + + const String & alias; + bool done = false; + + void visit(ASTSubquery &, ASTPtr & ast) + { + if (done) + return; + ast->setAlias(alias); + done = true; + } +}; + bool needRewrite(ASTSelectQuery & select, std::vector & table_expressions) { if (!select.tables()) @@ -354,6 +372,8 @@ bool needRewrite(ASTSelectQuery & select, std::vector; using RewriteVisitor = InDepthNodeVisitor; +using SetSubqueryAliasMatcher = OneTypeMatcher; +using SetSubqueryAliasVisitor = InDepthNodeVisitor; using ExtractAsterisksVisitor = ExtractAsterisksMatcher::Visitor; using ColumnAliasesVisitor = InDepthNodeVisitor; using AppendSemanticMatcher = OneTypeMatcher; @@ -419,6 +439,14 @@ void JoinToSubqueryTransformMatcher::visit(ASTSelectQuery & select, ASTPtr & ast if (!left_table) throw Exception("Cannot replace tables with subselect", ErrorCodes::LOGICAL_ERROR); + /// attach an alias to subquery. + /// TODO: remove setting check after testing period + if (data.context.getSettingsRef().subquery_requires_alias) + { + SetSubqueryAliasVisitor::Data alias_data{String("--.join") + std::to_string(i)}; + SetSubqueryAliasVisitor(alias_data).visit(left_table); + } + /// attach data to generated asterisk AppendSemanticVisitor::Data semantic_data{rev_aliases, false}; AppendSemanticVisitor(semantic_data).visit(left_table); diff --git a/dbms/src/Interpreters/SyntaxAnalyzer.cpp b/dbms/src/Interpreters/SyntaxAnalyzer.cpp index 0c73beeef16..ad1b45ef4d7 100644 --- a/dbms/src/Interpreters/SyntaxAnalyzer.cpp +++ b/dbms/src/Interpreters/SyntaxAnalyzer.cpp @@ -50,6 +50,7 @@ namespace ErrorCodes extern const int NOT_IMPLEMENTED; extern const int UNKNOWN_IDENTIFIER; extern const int EXPECTED_ALL_OR_ANY; + extern const int ALIAS_REQUIRED; } NameSet removeDuplicateColumns(NamesAndTypesList & columns) @@ -99,14 +100,22 @@ void translateQualifiedNames(ASTPtr & query, const ASTSelectQuery & select_query const Names & source_columns_list, const NameSet & source_columns_set, const NameSet & columns_from_joined_table) { + auto & settings = context.getSettingsRef(); + std::vector tables_with_columns = getDatabaseAndTablesWithColumnNames(select_query, context); + if (settings.subquery_requires_alias && tables_with_columns.size() > 1) + { + for (auto & pr : tables_with_columns) + if (pr.first.table.empty() && pr.first.alias.empty()) + throw Exception("Not unique subquery in FROM requires an alias (or subquery_requires_alias=0 to disable restriction).", + ErrorCodes::ALIAS_REQUIRED); + } if (tables_with_columns.empty()) { Names all_columns_name = source_columns_list; - /// TODO: asterisk_left_columns_only probably does not work in some cases - if (!context.getSettingsRef().asterisk_left_columns_only) + if (!settings.asterisk_left_columns_only) { for (auto & column : columns_from_joined_table) all_columns_name.emplace_back(column); diff --git a/dbms/tests/queries/0_stateless/00049_any_left_join.sql b/dbms/tests/queries/0_stateless/00049_any_left_join.sql index 28f8c43fe2f..ecd079a5085 100644 --- a/dbms/tests/queries/0_stateless/00049_any_left_join.sql +++ b/dbms/tests/queries/0_stateless/00049_any_left_join.sql @@ -1 +1 @@ -SELECT number, joined FROM system.numbers ANY LEFT JOIN (SELECT number * 2 AS number, number * 10 + 1 AS joined FROM system.numbers LIMIT 10) USING number LIMIT 10 +SELECT number, joined FROM system.numbers ANY LEFT JOIN (SELECT number * 2 AS number, number * 10 + 1 AS joined FROM system.numbers LIMIT 10) js2 USING number LIMIT 10 diff --git a/dbms/tests/queries/0_stateless/00052_all_left_join.sql b/dbms/tests/queries/0_stateless/00052_all_left_join.sql index d7221bd2d8f..6d5a1ba073c 100644 --- a/dbms/tests/queries/0_stateless/00052_all_left_join.sql +++ b/dbms/tests/queries/0_stateless/00052_all_left_join.sql @@ -1,9 +1,9 @@ SELECT * FROM ( SELECT number AS k FROM system.numbers LIMIT 10 -) +) js1 ALL LEFT JOIN ( SELECT intDiv(number, 2) AS k, number AS joined FROM system.numbers LIMIT 10 -) +) js2 USING k; diff --git a/dbms/tests/queries/0_stateless/00054_join_string.sql b/dbms/tests/queries/0_stateless/00054_join_string.sql index 7912a08c1d6..274b19dc075 100644 --- a/dbms/tests/queries/0_stateless/00054_join_string.sql +++ b/dbms/tests/queries/0_stateless/00054_join_string.sql @@ -1,9 +1,9 @@ SELECT * FROM ( SELECT reinterpretAsString(number + reinterpretAsUInt8('A')) AS k FROM system.numbers LIMIT 10 -) +) js1 ALL LEFT JOIN ( SELECT reinterpretAsString(intDiv(number, 2) + reinterpretAsUInt8('A')) AS k, number AS joined FROM system.numbers LIMIT 10 -) +) js2 USING k; diff --git a/dbms/tests/queries/0_stateless/00055_join_two_numbers.sql b/dbms/tests/queries/0_stateless/00055_join_two_numbers.sql index 2161b1af92a..76c38bac41e 100644 --- a/dbms/tests/queries/0_stateless/00055_join_two_numbers.sql +++ b/dbms/tests/queries/0_stateless/00055_join_two_numbers.sql @@ -1,9 +1,9 @@ SELECT left, right FROM ( SELECT number % 4 AS k1, number % 3 AS k2, number AS left FROM system.numbers LIMIT 10 -) +) js1 ALL LEFT JOIN ( SELECT number % 2 AS k1, number % 6 AS k2, number AS right FROM system.numbers LIMIT 10 -) +) js2 USING k1, k2; diff --git a/dbms/tests/queries/0_stateless/00056_join_number_string.sql b/dbms/tests/queries/0_stateless/00056_join_number_string.sql index 9b88025f7aa..db10ad99b27 100644 --- a/dbms/tests/queries/0_stateless/00056_join_number_string.sql +++ b/dbms/tests/queries/0_stateless/00056_join_number_string.sql @@ -1,9 +1,9 @@ SELECT left, right FROM ( SELECT number % 4 AS k1, toString(number % 3) AS k2, number AS left FROM system.numbers LIMIT 10 -) +) js1 ALL LEFT JOIN ( SELECT number % 2 AS k1, toString(number % 6) AS k2, number AS right FROM system.numbers LIMIT 10 -) +) js2 USING k1, k2; diff --git a/dbms/tests/queries/0_stateless/00057_join_aliases.sql b/dbms/tests/queries/0_stateless/00057_join_aliases.sql index c98de98f43c..6568e36fbda 100644 --- a/dbms/tests/queries/0_stateless/00057_join_aliases.sql +++ b/dbms/tests/queries/0_stateless/00057_join_aliases.sql @@ -1 +1 @@ -SELECT number, number / 2 AS n, j1, j2 FROM system.numbers ANY LEFT JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 10) USING n LIMIT 10 +SELECT number, number / 2 AS n, j1, j2 FROM system.numbers ANY LEFT JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 10) js2 USING n LIMIT 10 diff --git a/dbms/tests/queries/0_stateless/00098_l_union_all.sql b/dbms/tests/queries/0_stateless/00098_l_union_all.sql index 414baba92fa..59c3711ebc2 100644 --- a/dbms/tests/queries/0_stateless/00098_l_union_all.sql +++ b/dbms/tests/queries/0_stateless/00098_l_union_all.sql @@ -1,5 +1,5 @@ SET any_join_distinct_right_table_keys = 1; -SELECT a,b,c,d FROM (SELECT 1 AS a,2 AS b, 3 AS c UNION ALL SELECT 2,3,4 ) ANY INNER JOIN (SELECT 1 AS a,2 AS b,4 AS d UNION ALL SELECT 2,3,5) USING (a) ORDER BY a,b,c,d ASC; -SELECT a,b,c,d FROM (SELECT 1 AS a,2 AS b, 3 AS c UNION ALL SELECT 2,3,4 ) ALL LEFT JOIN (SELECT 1 AS a,2 AS b,4 AS d UNION ALL SELECT 2,3,5) USING (a) ORDER BY a,b,c,d ASC; -SELECT a,b,c,d FROM (SELECT 1 AS a,2 AS b, 3 AS c UNION ALL SELECT 2,3,4 ) ALL LEFT JOIN (SELECT 1 AS a,2 AS b,4 AS d UNION ALL SELECT 2,3,5) USING a,b ORDER BY a,b,c,d ASC; +SELECT a,b,c,d FROM (SELECT 1 AS a,2 AS b, 3 AS c UNION ALL SELECT 2,3,4 ) js1 ANY INNER JOIN (SELECT 1 AS a,2 AS b,4 AS d UNION ALL SELECT 2,3,5) js2 USING (a) ORDER BY a,b,c,d ASC; +SELECT a,b,c,d FROM (SELECT 1 AS a,2 AS b, 3 AS c UNION ALL SELECT 2,3,4 ) js1 ALL LEFT JOIN (SELECT 1 AS a,2 AS b,4 AS d UNION ALL SELECT 2,3,5) js2 USING (a) ORDER BY a,b,c,d ASC; +SELECT a,b,c,d FROM (SELECT 1 AS a,2 AS b, 3 AS c UNION ALL SELECT 2,3,4 ) js1 ALL LEFT JOIN (SELECT 1 AS a,2 AS b,4 AS d UNION ALL SELECT 2,3,5) js2 USING a,b ORDER BY a,b,c,d ASC; diff --git a/dbms/tests/queries/0_stateless/00099_join_many_blocks_segfault.sql b/dbms/tests/queries/0_stateless/00099_join_many_blocks_segfault.sql index f7734980547..7219bcecf55 100644 --- a/dbms/tests/queries/0_stateless/00099_join_many_blocks_segfault.sql +++ b/dbms/tests/queries/0_stateless/00099_join_many_blocks_segfault.sql @@ -11,4 +11,4 @@ ANY LEFT JOIN SELECT 2 AS DomainID, 'def' AS Domain -) USING DomainID; +) js2 USING DomainID; diff --git a/dbms/tests/queries/0_stateless/00118_storage_join.sql b/dbms/tests/queries/0_stateless/00118_storage_join.sql index 358b6158989..9da8829e5c7 100644 --- a/dbms/tests/queries/0_stateless/00118_storage_join.sql +++ b/dbms/tests/queries/0_stateless/00118_storage_join.sql @@ -3,9 +3,9 @@ DROP TABLE IF EXISTS join; CREATE TABLE join (k UInt64, s String) ENGINE = Join(ANY, LEFT, k); INSERT INTO join VALUES (1, 'abc'), (2, 'def'); -SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k; +SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) js1 ANY LEFT JOIN join USING k; INSERT INTO join VALUES (6, 'ghi'); -SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k; +SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) js1 ANY LEFT JOIN join USING k; DROP TABLE join; diff --git a/dbms/tests/queries/0_stateless/00119_storage_join.sql b/dbms/tests/queries/0_stateless/00119_storage_join.sql index 3e76d46a12f..735ef2da16a 100644 --- a/dbms/tests/queries/0_stateless/00119_storage_join.sql +++ b/dbms/tests/queries/0_stateless/00119_storage_join.sql @@ -6,9 +6,9 @@ INSERT INTO join VALUES ('abc', [0], 1), ('def', [1, 2], 2); INSERT INTO join (k, s) VALUES (3, 'ghi'); INSERT INTO join (x, k) VALUES ([3, 4, 5], 4); -SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k; -SELECT s, x FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k; -SELECT x, s, k FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k; -SELECT 1, x, 2, s, 3, k, 4 FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k; +SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) js1 ANY LEFT JOIN join USING k; +SELECT s, x FROM (SELECT number AS k FROM system.numbers LIMIT 10) js1 ANY LEFT JOIN join USING k; +SELECT x, s, k FROM (SELECT number AS k FROM system.numbers LIMIT 10) js1 ANY LEFT JOIN join USING k; +SELECT 1, x, 2, s, 3, k, 4 FROM (SELECT number AS k FROM system.numbers LIMIT 10) js1 ANY LEFT JOIN join USING k; DROP TABLE join; diff --git a/dbms/tests/queries/0_stateless/00120_join_and_group_by.sql b/dbms/tests/queries/0_stateless/00120_join_and_group_by.sql index bd9c5656cad..21168443ee4 100644 --- a/dbms/tests/queries/0_stateless/00120_join_and_group_by.sql +++ b/dbms/tests/queries/0_stateless/00120_join_and_group_by.sql @@ -1,2 +1,6 @@ -SELECT value FROM system.one ANY LEFT JOIN (SELECT dummy, dummy AS value) USING dummy GROUP BY value; -SELECT value1, value2, sum(number) FROM (SELECT number, intHash64(number) AS value1 FROM system.numbers LIMIT 10) ANY LEFT JOIN (SELECT number, intHash32(number) AS value2 FROM system.numbers LIMIT 10) USING number GROUP BY value1, value2; +SELECT value FROM system.one ANY LEFT JOIN (SELECT dummy, dummy AS value) js2 USING dummy GROUP BY value; + +SELECT value1, value2, sum(number) +FROM (SELECT number, intHash64(number) AS value1 FROM system.numbers LIMIT 10) js1 +ANY LEFT JOIN (SELECT number, intHash32(number) AS value2 FROM system.numbers LIMIT 10) js2 +USING number GROUP BY value1, value2; diff --git a/dbms/tests/queries/0_stateless/00122_join_with_subquery_with_subquery.sql b/dbms/tests/queries/0_stateless/00122_join_with_subquery_with_subquery.sql index 19a91654ca9..0cb3de94a55 100644 --- a/dbms/tests/queries/0_stateless/00122_join_with_subquery_with_subquery.sql +++ b/dbms/tests/queries/0_stateless/00122_join_with_subquery_with_subquery.sql @@ -1 +1 @@ -SELECT 1 AS k FROM system.one ANY LEFT JOIN (SELECT k FROM (SELECT 1 AS k, 2 AS x)) USING k; +SELECT 1 AS k FROM system.one ANY LEFT JOIN (SELECT k FROM (SELECT 1 AS k, 2 AS x)) js2 USING k; diff --git a/dbms/tests/queries/0_stateless/00150_with_totals_and_join.sql b/dbms/tests/queries/0_stateless/00150_with_totals_and_join.sql index 1c369da7491..c06a7ea335d 100644 --- a/dbms/tests/queries/0_stateless/00150_with_totals_and_join.sql +++ b/dbms/tests/queries/0_stateless/00150_with_totals_and_join.sql @@ -1,3 +1,5 @@ +SET subquery_requires_alias = 0; + SELECT k, s1, s2 FROM (SELECT intDiv(number, 3) AS k, sum(number) AS s1 FROM (SELECT * FROM system.numbers LIMIT 10) GROUP BY k) ANY LEFT JOIN (SELECT intDiv(number, 4) AS k, sum(number) AS s2 FROM (SELECT * FROM system.numbers LIMIT 10) GROUP BY k) USING k ORDER BY k; SELECT k, s1, s2 FROM (SELECT intDiv(number, 3) AS k, sum(number) AS s1 FROM (SELECT * FROM system.numbers LIMIT 10) GROUP BY k WITH TOTALS) ANY LEFT JOIN (SELECT intDiv(number, 4) AS k, sum(number) AS s2 FROM (SELECT * FROM system.numbers LIMIT 10) GROUP BY k) USING k ORDER BY k; SELECT k, s1, s2 FROM (SELECT intDiv(number, 3) AS k, sum(number) AS s1 FROM (SELECT * FROM system.numbers LIMIT 10) GROUP BY k) ANY LEFT JOIN (SELECT intDiv(number, 4) AS k, sum(number) AS s2 FROM (SELECT * FROM system.numbers LIMIT 10) GROUP BY k WITH TOTALS) USING k ORDER BY k; diff --git a/dbms/tests/queries/0_stateless/00162_shard_global_join.sql b/dbms/tests/queries/0_stateless/00162_shard_global_join.sql index 72e112620ee..af56407e3d5 100644 --- a/dbms/tests/queries/0_stateless/00162_shard_global_join.sql +++ b/dbms/tests/queries/0_stateless/00162_shard_global_join.sql @@ -1 +1 @@ -SELECT toFloat64(dummy + 2) AS n, j1, j2 FROM remote('127.0.0.{2,3}', system.one) GLOBAL ANY LEFT JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 10) USING n LIMIT 10; +SELECT toFloat64(dummy + 2) AS n, j1, j2 FROM remote('127.0.0.{2,3}', system.one) jr1 GLOBAL ANY LEFT JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 10) jr2 USING n LIMIT 10; diff --git a/dbms/tests/queries/0_stateless/00163_shard_join_with_empty_table.sql b/dbms/tests/queries/0_stateless/00163_shard_join_with_empty_table.sql index b6e1a260d25..c9eeecd0564 100644 --- a/dbms/tests/queries/0_stateless/00163_shard_join_with_empty_table.sql +++ b/dbms/tests/queries/0_stateless/00163_shard_join_with_empty_table.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT number, number / 2 AS n, j1, j2 FROM remote('127.0.0.{2,3}', system.numbers) ANY LEFT JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 0) USING n LIMIT 10; SELECT dummy + 2 AS number, number / 2 AS n, j1, j2 FROM remote('127.0.0.{2,3}', system.one) ANY INNER JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 0) USING n LIMIT 10; diff --git a/dbms/tests/queries/0_stateless/00169_join_constant_keys.sql b/dbms/tests/queries/0_stateless/00169_join_constant_keys.sql index 93c98271ca7..16ab696c0f3 100644 --- a/dbms/tests/queries/0_stateless/00169_join_constant_keys.sql +++ b/dbms/tests/queries/0_stateless/00169_join_constant_keys.sql @@ -8,10 +8,10 @@ FROM arrayJoin([1, 2, 3]) AS key1, 0 AS key2, 999 AS table_1 -) ALL INNER JOIN +) js1 ALL INNER JOIN ( SELECT arrayJoin([1, 3, 2]) AS key1, 0 AS key2, 999 AS table_1 -) USING key2, key1; +) js2 USING key2, key1; diff --git a/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics.sql b/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics.sql index 8e87f49a7a2..54e71e6181b 100644 --- a/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics.sql +++ b/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; DROP TABLE IF EXISTS series; diff --git a/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics_stable.sql b/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics_stable.sql index f51722f7f33..9f4457157fb 100644 --- a/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics_stable.sql +++ b/dbms/tests/queries/0_stateless/00181_aggregate_functions_statistics_stable.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; DROP TABLE IF EXISTS series; diff --git a/dbms/tests/queries/0_stateless/00202_cross_join.sql b/dbms/tests/queries/0_stateless/00202_cross_join.sql index 5b23b60d8e3..ed435d90021 100644 --- a/dbms/tests/queries/0_stateless/00202_cross_join.sql +++ b/dbms/tests/queries/0_stateless/00202_cross_join.sql @@ -1 +1 @@ -SELECT x, y FROM (SELECT number AS x FROM system.numbers LIMIT 3) CROSS JOIN (SELECT number AS y FROM system.numbers LIMIT 5); +SELECT x, y FROM (SELECT number AS x FROM system.numbers LIMIT 3) js1 CROSS JOIN (SELECT number AS y FROM system.numbers LIMIT 5) js2; diff --git a/dbms/tests/queries/0_stateless/00203_full_join.sql b/dbms/tests/queries/0_stateless/00203_full_join.sql index f664ae3bd95..4b672c4f318 100644 --- a/dbms/tests/queries/0_stateless/00203_full_join.sql +++ b/dbms/tests/queries/0_stateless/00203_full_join.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT k, x, y FROM (SELECT arrayJoin([1, 2, 3]) AS k, 'Hello' AS x) ANY FULL JOIN (SELECT range(k) AS y, arrayJoin([3, 4, 5]) AS k) USING k WHERE k < 10 ORDER BY k; SELECT k, x FROM (SELECT arrayJoin([1, 2, 3]) AS k, 'Hello' AS x) ANY FULL JOIN (SELECT range(k) AS y, arrayJoin([3, 4, 5]) AS k) USING k WHERE k < 10 ORDER BY k; diff --git a/dbms/tests/queries/0_stateless/00217_shard_global_subquery_columns_with_same_name.sql b/dbms/tests/queries/0_stateless/00217_shard_global_subquery_columns_with_same_name.sql index 503edb359f1..9e47e3d7a7c 100644 --- a/dbms/tests/queries/0_stateless/00217_shard_global_subquery_columns_with_same_name.sql +++ b/dbms/tests/queries/0_stateless/00217_shard_global_subquery_columns_with_same_name.sql @@ -1,2 +1,4 @@ +SET subquery_requires_alias = 0; + SELECT k, a FROM (SELECT 42 AS k FROM remote('127.0.0.2', system.one)) GLOBAL ALL FULL OUTER JOIN (SELECT 42 AS k, 1 AS a, a) USING k; SELECT 1 FROM remote('127.0.0.2', system.one) WHERE (1, 1) GLOBAL IN (SELECT 1 AS a, a); diff --git a/dbms/tests/queries/0_stateless/00219_full_right_join_column_order.sql b/dbms/tests/queries/0_stateless/00219_full_right_join_column_order.sql index 9c7485992f6..76098261358 100644 --- a/dbms/tests/queries/0_stateless/00219_full_right_join_column_order.sql +++ b/dbms/tests/queries/0_stateless/00219_full_right_join_column_order.sql @@ -1,8 +1,8 @@ SET any_join_distinct_right_table_keys = 1; -SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b) USING a, b; -SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b) USING b, a; +SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) js1 ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b) js2 USING a, b; +SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) js1 ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b) js2 USING b, a; -SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b UNION ALL SELECT 1 AS a, 2000 AS b) USING a, b; -SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b UNION ALL SELECT 1 AS a, 2000 AS b) USING b, a; +SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) js1 ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b UNION ALL SELECT 1 AS a, 2000 AS b) js2 USING a, b; +SELECT a, b FROM (SELECT 1 AS a, 2000 AS b) js1 ANY RIGHT JOIN (SELECT 2 AS a, 3000 AS b UNION ALL SELECT 1 AS a, 2000 AS b) js2 USING b, a; diff --git a/dbms/tests/queries/0_stateless/00225_join_duplicate_columns.sql b/dbms/tests/queries/0_stateless/00225_join_duplicate_columns.sql index b4e02c153d5..6cb4647cd14 100644 --- a/dbms/tests/queries/0_stateless/00225_join_duplicate_columns.sql +++ b/dbms/tests/queries/0_stateless/00225_join_duplicate_columns.sql @@ -1,9 +1,9 @@ -select b from (select 1 as a, 42 as c) any left join (select 2 as b, 2 as b, 41 as c) using c; -select b from (select 1 as a, 42 as c) any left join (select 2 as b, 2 as b, 42 as c) using c; +select b from (select 1 as a, 42 as c) js1 any left join (select 2 as b, 2 as b, 41 as c) js2 using c; +select b from (select 1 as a, 42 as c) js1 any left join (select 2 as b, 2 as b, 42 as c) js2 using c; select c,a,a,b,b from - (select 1 as a, 1 as a, 42 as c group by c order by a,c) + (select 1 as a, 1 as a, 42 as c group by c order by a,c) js1 any left join - (select 2 as b, 2 as b, 41 as c group by c order by b,c) + (select 2 as b, 2 as b, 41 as c group by c order by b,c) js2 using c order by b; diff --git a/dbms/tests/queries/0_stateless/00316_rounding_functions_and_empty_block.sql b/dbms/tests/queries/0_stateless/00316_rounding_functions_and_empty_block.sql index 45dc76cb41d..9f91cd713ae 100644 --- a/dbms/tests/queries/0_stateless/00316_rounding_functions_and_empty_block.sql +++ b/dbms/tests/queries/0_stateless/00316_rounding_functions_and_empty_block.sql @@ -6,8 +6,8 @@ FROM ( SELECT 6534090703218709881 AS DeviceIDHash, 1458586663 AS InstallTimestamp UNION ALL SELECT 2697418689476658272, 1458561552 -) ANY INNER JOIN +) js1 ANY INNER JOIN ( SELECT 1034415739529768519 AS DeviceIDHash, 1458566664 AS ReferrerTimestamp UNION ALL SELECT 2697418689476658272, 1458561552 -) USING DeviceIDHash; +) js2 USING DeviceIDHash; diff --git a/dbms/tests/queries/0_stateless/00353_join_by_tuple.sql b/dbms/tests/queries/0_stateless/00353_join_by_tuple.sql index 5550effec2c..99019f53cff 100644 --- a/dbms/tests/queries/0_stateless/00353_join_by_tuple.sql +++ b/dbms/tests/queries/0_stateless/00353_join_by_tuple.sql @@ -1,2 +1,2 @@ set any_join_distinct_right_table_keys = 1; -select a from (select (1, 2) as a) any inner join (select (1, 2) as a) using a; +select a from (select (1, 2) as a) js1 any inner join (select (1, 2) as a) js2 using a; diff --git a/dbms/tests/queries/0_stateless/00370_duplicate_columns_in_subqueries.sql b/dbms/tests/queries/0_stateless/00370_duplicate_columns_in_subqueries.sql index fb6b6ccfe34..2c35e160a9d 100644 --- a/dbms/tests/queries/0_stateless/00370_duplicate_columns_in_subqueries.sql +++ b/dbms/tests/queries/0_stateless/00370_duplicate_columns_in_subqueries.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; select x, y from (select 1 as x, 2 as y, x, y); select x, y from (select 1 as x, 1 as y, x, y); diff --git a/dbms/tests/queries/0_stateless/00436_fixed_string_16_comparisons.sql b/dbms/tests/queries/0_stateless/00436_fixed_string_16_comparisons.sql index 12553970ed1..d22e9cbea84 100644 --- a/dbms/tests/queries/0_stateless/00436_fixed_string_16_comparisons.sql +++ b/dbms/tests/queries/0_stateless/00436_fixed_string_16_comparisons.sql @@ -12,7 +12,7 @@ FROM UNION ALL SELECT 'aaaaaaaabaaaaaaa' UNION ALL SELECT 'aaaaaaabaaaaaaaa' UNION ALL SELECT 'aaaaaaacaaaaaaaa' -) +) js1 CROSS JOIN ( SELECT 'aaaaaaaaaaaaaaaa' AS b @@ -24,7 +24,7 @@ CROSS JOIN UNION ALL SELECT 'aaaaaaaabaaaaaaa' UNION ALL SELECT 'aaaaaaabaaaaaaaa' UNION ALL SELECT 'aaaaaaacaaaaaaaa' -) +) js2 ORDER BY a, b; diff --git a/dbms/tests/queries/0_stateless/00444_join_use_nulls.sql b/dbms/tests/queries/0_stateless/00444_join_use_nulls.sql index 1992c3cbcc9..08e4fdcd49f 100644 --- a/dbms/tests/queries/0_stateless/00444_join_use_nulls.sql +++ b/dbms/tests/queries/0_stateless/00444_join_use_nulls.sql @@ -1,5 +1,6 @@ SET join_use_nulls = 0; SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT k, a, b FROM diff --git a/dbms/tests/queries/0_stateless/00445_join_nullable_keys.sql b/dbms/tests/queries/0_stateless/00445_join_nullable_keys.sql index fa5fec58364..2b8f2ca5f44 100644 --- a/dbms/tests/queries/0_stateless/00445_join_nullable_keys.sql +++ b/dbms/tests/queries/0_stateless/00445_join_nullable_keys.sql @@ -5,28 +5,28 @@ SELECT k, a, b FROM ( SELECT nullIf(number, 7) AS k, toString(number) AS a FROM system.numbers LIMIT 10 -) +) js1 ANY INNER JOIN ( SELECT number AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10 -) USING (k) ORDER BY k; +) js2 USING (k) ORDER BY k; SELECT k, a, b FROM ( SELECT number AS k, toString(number) AS a FROM system.numbers LIMIT 10 -) +) js1 ANY LEFT JOIN ( SELECT nullIf(number, 8) AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10 -) USING (k) ORDER BY k; +) js2 USING (k) ORDER BY k; SELECT k, a, b FROM ( SELECT nullIf(number, 7) AS k, toString(number) AS a FROM system.numbers LIMIT 10 -) +) js1 ANY RIGHT JOIN ( SELECT nullIf(number, 8) AS k, toString(number) AS b FROM system.numbers LIMIT 5, 10 -) USING (k) ORDER BY k; +) js2 USING (k) ORDER BY k; diff --git a/dbms/tests/queries/0_stateless/00475_in_join_db_table.sql b/dbms/tests/queries/0_stateless/00475_in_join_db_table.sql index 3e5a5237468..5f90d108015 100644 --- a/dbms/tests/queries/0_stateless/00475_in_join_db_table.sql +++ b/dbms/tests/queries/0_stateless/00475_in_join_db_table.sql @@ -13,11 +13,11 @@ DROP TABLE set; DROP TABLE IF EXISTS join; CREATE TABLE join (k UInt8, x String) ENGINE = Memory; INSERT INTO join VALUES (1, 'hello'); -SELECT k, x FROM (SELECT arrayJoin([1, 2]) AS k) ANY LEFT JOIN join USING k; +SELECT k, x FROM (SELECT arrayJoin([1, 2]) AS k) js1 ANY LEFT JOIN join USING k; DROP TABLE join; CREATE TABLE join (k UInt8, x String) ENGINE = Join(ANY, LEFT, k); INSERT INTO join VALUES (1, 'hello'); -SELECT k, x FROM (SELECT arrayJoin([1, 2]) AS k) ANY LEFT JOIN join USING k; +SELECT k, x FROM (SELECT arrayJoin([1, 2]) AS k) js1 ANY LEFT JOIN join USING k; DROP TABLE join; diff --git a/dbms/tests/queries/0_stateless/00549_join_use_nulls.sql b/dbms/tests/queries/0_stateless/00549_join_use_nulls.sql index fd2ec04dbc5..6ed34fd5fcd 100644 --- a/dbms/tests/queries/0_stateless/00549_join_use_nulls.sql +++ b/dbms/tests/queries/0_stateless/00549_join_use_nulls.sql @@ -14,7 +14,7 @@ FROM toString(number) AS a FROM system.numbers LIMIT 2 -) +) js1 ANY LEFT JOIN ( SELECT @@ -22,7 +22,7 @@ ANY LEFT JOIN toString(number) AS b FROM system.numbers LIMIT 1, 2 -) USING (k) +) js2 USING (k) ORDER BY k ASC; SELECT * FROM null_00549 ORDER BY k, a, b; diff --git a/dbms/tests/queries/0_stateless/00555_right_join_excessive_rows.sql b/dbms/tests/queries/0_stateless/00555_right_join_excessive_rows.sql index 72ccbd4e58d..29cc40c009f 100644 --- a/dbms/tests/queries/0_stateless/00555_right_join_excessive_rows.sql +++ b/dbms/tests/queries/0_stateless/00555_right_join_excessive_rows.sql @@ -1,3 +1,3 @@ SET any_join_distinct_right_table_keys = 1; SET max_block_size = 10; -SELECT * FROM (select toUInt64(1) s limit 1) any right join (select number s, s as x from numbers(11)) using (s) ORDER BY s; +SELECT * FROM (select toUInt64(1) s limit 1) js1 any right join (select number s, s as x from numbers(11)) js2 using (s) ORDER BY s; diff --git a/dbms/tests/queries/0_stateless/00561_storage_join.sql b/dbms/tests/queries/0_stateless/00561_storage_join.sql index bcbaaded9b0..08f76815702 100644 --- a/dbms/tests/queries/0_stateless/00561_storage_join.sql +++ b/dbms/tests/queries/0_stateless/00561_storage_join.sql @@ -35,7 +35,7 @@ from joinbug; select id, id2, val, val2, created from ( SELECT toUInt64(arrayJoin(range(50))) AS id2 -) +) js1 ANY INNER JOIN joinbug_join using id2; DROP TABLE joinbug; diff --git a/dbms/tests/queries/0_stateless/00563_complex_in_expression.sql b/dbms/tests/queries/0_stateless/00563_complex_in_expression.sql index 86ad484d97a..cd80b9c3a7a 100644 --- a/dbms/tests/queries/0_stateless/00563_complex_in_expression.sql +++ b/dbms/tests/queries/0_stateless/00563_complex_in_expression.sql @@ -20,7 +20,7 @@ ALL INNER JOIN data FROM join_with_index WHERE toUInt64(data) IN (0, 529335254087962442) -) USING (key); +) js2 USING (key); SELECT _uniq, _uniq IN (0, 99) FROM join_with_index diff --git a/dbms/tests/queries/0_stateless/00577_full_join_segfault.sql b/dbms/tests/queries/0_stateless/00577_full_join_segfault.sql index d2fdab7c1c3..bd03d565746 100644 --- a/dbms/tests/queries/0_stateless/00577_full_join_segfault.sql +++ b/dbms/tests/queries/0_stateless/00577_full_join_segfault.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT k, a1, b1, a2, b2 FROM (SELECT 0 AS k, 'hello' AS a1, 123 AS b1, a1) ANY FULL OUTER JOIN (SELECT 1 AS k, 'hello' AS a2, 456 AS b2, a2) USING (k) ORDER BY k; SELECT k, a, b FROM (SELECT 0 AS k, 'hello' AS a, 123 AS b, a) ANY FULL OUTER JOIN (SELECT 1 AS k) USING (k) ORDER BY k; diff --git a/dbms/tests/queries/0_stateless/00585_union_all_subquery_aggregation_column_removal.sql b/dbms/tests/queries/0_stateless/00585_union_all_subquery_aggregation_column_removal.sql index d79e91ed0b9..47e6582134a 100644 --- a/dbms/tests/queries/0_stateless/00585_union_all_subquery_aggregation_column_removal.sql +++ b/dbms/tests/queries/0_stateless/00585_union_all_subquery_aggregation_column_removal.sql @@ -189,7 +189,7 @@ FROM GROUP BY domain ORDER BY domain LIMIT 10 -) +) js1 ALL FULL OUTER JOIN ( SELECT @@ -214,7 +214,7 @@ UNION ALL GROUP BY domain ORDER BY domain LIMIT 10 -) +) js2 USING (total, domain) ORDER BY total, domain; @@ -243,7 +243,7 @@ FROM GROUP BY domain ORDER BY domain LIMIT 10 -) +) js1 ALL FULL OUTER JOIN ( SELECT @@ -268,7 +268,7 @@ UNION ALL GROUP BY domain ORDER BY domain LIMIT 10 -) +) js2 USING (total, domain) ORDER BY total, domain; @@ -297,7 +297,7 @@ FROM GROUP BY domain ORDER BY domain LIMIT 10 -) +) js1 ALL FULL OUTER JOIN ( SELECT @@ -322,7 +322,7 @@ UNION ALL GROUP BY domain ORDER BY domain LIMIT 10 -) +) js2 USING (total, domain) ORDER BY total, domain; diff --git a/dbms/tests/queries/0_stateless/00586_removing_unused_columns_from_subquery.sql b/dbms/tests/queries/0_stateless/00586_removing_unused_columns_from_subquery.sql index 07ea077a460..3d6ca282de4 100644 --- a/dbms/tests/queries/0_stateless/00586_removing_unused_columns_from_subquery.sql +++ b/dbms/tests/queries/0_stateless/00586_removing_unused_columns_from_subquery.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; DROP TABLE IF EXISTS local_statements; DROP TABLE IF EXISTS statements; diff --git a/dbms/tests/queries/0_stateless/00597_push_down_predicate.sql b/dbms/tests/queries/0_stateless/00597_push_down_predicate.sql index e0d92b87e5c..a2063263843 100644 --- a/dbms/tests/queries/0_stateless/00597_push_down_predicate.sql +++ b/dbms/tests/queries/0_stateless/00597_push_down_predicate.sql @@ -1,5 +1,6 @@ SET send_logs_level = 'none'; SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; DROP TABLE IF EXISTS test_00597; DROP TABLE IF EXISTS test_view_00597; diff --git a/dbms/tests/queries/0_stateless/00612_pk_in_tuple.sql b/dbms/tests/queries/0_stateless/00612_pk_in_tuple.sql index c774ab71932..499474d1b0a 100644 --- a/dbms/tests/queries/0_stateless/00612_pk_in_tuple.sql +++ b/dbms/tests/queries/0_stateless/00612_pk_in_tuple.sql @@ -34,9 +34,9 @@ select 'max(key) from tab_00612 where (key, left array join n.x) in ((1, 1), (2, select max(key) from tab_00612 left array join `n.x` as val where (key, val) in ((1, 1), (2, 2)); select max(key) from tab_00612 left array join n as val where (key, val.x) in ((1, 1), (2, 2)); select 'max(key) from tab_00612 any left join (select key, arrayJoin(n.x) as val from tab_00612) using key where (key, val) in (1, 1)'; -select max(key) from tab_00612 any left join (select key, arrayJoin(n.x) as val from tab_00612) using key where (key, val) in (1, 1); +select max(key) from tab_00612 any left join (select key, arrayJoin(n.x) as val from tab_00612) js2 using key where (key, val) in (1, 1); select 'max(key) from tab_00612 any left join (select key, arrayJoin(n.x) as val from tab_00612) using key where (key, val) in ((1, 1), (2, 2))'; -select max(key) from tab_00612 any left join (select key, arrayJoin(n.x) as val from tab_00612) using key where (key, val) in ((1, 1), (2, 2)); +select max(key) from tab_00612 any left join (select key, arrayJoin(n.x) as val from tab_00612) js2 using key where (key, val) in ((1, 1), (2, 2)); drop table if exists tab_00612; CREATE TABLE tab_00612 (key1 Int32, id1 Int64, c1 Int64) ENGINE = MergeTree PARTITION BY id1 ORDER BY (key1) ; diff --git a/dbms/tests/queries/0_stateless/00632_get_sample_block_cache.sql b/dbms/tests/queries/0_stateless/00632_get_sample_block_cache.sql index c7a41407910..5ba315389c6 100644 --- a/dbms/tests/queries/0_stateless/00632_get_sample_block_cache.sql +++ b/dbms/tests/queries/0_stateless/00632_get_sample_block_cache.sql @@ -1,3 +1,5 @@ +SET subquery_requires_alias = 0; + -- This test (SELECT) without cache can take tens minutes DROP TABLE IF EXISTS dict_string; DROP TABLE IF EXISTS dict_ui64; diff --git a/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql b/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql index 4a57f49bbe3..3042e77f343 100644 --- a/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql +++ b/dbms/tests/queries/0_stateless/00674_join_on_syntax.sql @@ -1,3 +1,5 @@ +SET subquery_requires_alias = 0; + drop table if exists tab1; drop table if exists tab2; drop table if exists tab3; diff --git a/dbms/tests/queries/0_stateless/00679_replace_asterisk.sql b/dbms/tests/queries/0_stateless/00679_replace_asterisk.sql index 6ac119bdf48..e3511d47043 100644 --- a/dbms/tests/queries/0_stateless/00679_replace_asterisk.sql +++ b/dbms/tests/queries/0_stateless/00679_replace_asterisk.sql @@ -1,4 +1,5 @@ set any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT * FROM (SELECT 1 AS id, 2 AS value); SELECT * FROM (SELECT 1 AS id, 2 AS value, 3 AS A) ANY INNER JOIN (SELECT 1 AS id, 4 AS values, 5 AS D) USING id; diff --git a/dbms/tests/queries/0_stateless/00701_join_default_strictness.sql b/dbms/tests/queries/0_stateless/00701_join_default_strictness.sql index f2381f54e75..873911a944d 100644 --- a/dbms/tests/queries/0_stateless/00701_join_default_strictness.sql +++ b/dbms/tests/queries/0_stateless/00701_join_default_strictness.sql @@ -13,8 +13,8 @@ INSERT INTO a2 VALUES (1, 2); INSERT INTO a2 VALUES (1, 3); INSERT INTO a2 VALUES (1, 4); -SELECT a, b FROM a1 LEFT JOIN (SELECT a, b FROM a2) USING a ORDER BY b SETTINGS join_default_strictness='ANY'; -SELECT a, b FROM a1 LEFT JOIN (SELECT a, b FROM a2) USING a ORDER BY b; -- default SETTINGS join_default_strictness='ALL'; +SELECT a, b FROM a1 LEFT JOIN (SELECT a, b FROM a2) js2 USING a ORDER BY b SETTINGS join_default_strictness='ANY'; +SELECT a, b FROM a1 LEFT JOIN (SELECT a, b FROM a2) js2 USING a ORDER BY b; -- default SETTINGS join_default_strictness='ALL'; DROP TABLE IF EXISTS a1; DROP TABLE IF EXISTS a2; diff --git a/dbms/tests/queries/0_stateless/00702_join_with_using.sql b/dbms/tests/queries/0_stateless/00702_join_with_using.sql index d30ce2293fc..b70d31714f2 100644 --- a/dbms/tests/queries/0_stateless/00702_join_with_using.sql +++ b/dbms/tests/queries/0_stateless/00702_join_with_using.sql @@ -7,7 +7,7 @@ CREATE TABLE using2(a UInt8, b UInt8) ENGINE=Memory; INSERT INTO using1 VALUES (1, 1) (2, 2) (3, 3); INSERT INTO using2 VALUES (4, 4) (2, 2) (3, 3); -SELECT * FROM using1 ALL LEFT JOIN (SELECT * FROM using2) USING (a, a, a, b, b, b, a, a) ORDER BY a; +SELECT * FROM using1 ALL LEFT JOIN (SELECT * FROM using2) js2 USING (a, a, a, b, b, b, a, a) ORDER BY a; DROP TABLE using1; DROP TABLE using2; @@ -30,6 +30,7 @@ select * from persons all inner join children using id; select * from persons all inner join (select * from children) as j using id; select * from (select * from persons) as s all inner join (select * from children ) as j using id; -- +set subquery_requires_alias = 0; select * from persons all inner join (select * from children) using id; select * from (select * from persons) all inner join (select * from children) using id; select * from (select * from persons) as s all inner join (select * from children) using id; diff --git a/dbms/tests/queries/0_stateless/00717_default_join_type.sql b/dbms/tests/queries/0_stateless/00717_default_join_type.sql index 2b04428cde2..2cdea08142d 100644 --- a/dbms/tests/queries/0_stateless/00717_default_join_type.sql +++ b/dbms/tests/queries/0_stateless/00717_default_join_type.sql @@ -7,7 +7,7 @@ CREATE TABLE default_join2(a Int64, b Int64) ENGINE=Memory; INSERT INTO default_join1 VALUES(1, 1), (2, 2), (3, 3); INSERT INTO default_join2 VALUES(3, 3), (4, 4); -SELECT a, b FROM default_join1 JOIN (SELECT a, b FROM default_join2) USING a ORDER BY b SETTINGS join_default_strictness='ANY'; +SELECT a, b FROM default_join1 JOIN (SELECT a, b FROM default_join2) js2 USING a ORDER BY b SETTINGS join_default_strictness='ANY'; DROP TABLE default_join1; DROP TABLE default_join2; diff --git a/dbms/tests/queries/0_stateless/00725_join_on_bug_2.sql b/dbms/tests/queries/0_stateless/00725_join_on_bug_2.sql index 047dd5c7c7d..e28d0467515 100644 --- a/dbms/tests/queries/0_stateless/00725_join_on_bug_2.sql +++ b/dbms/tests/queries/0_stateless/00725_join_on_bug_2.sql @@ -1,3 +1,5 @@ +set subquery_requires_alias = 0; + drop table if exists t_00725_2; drop table if exists s_00725_2; diff --git a/dbms/tests/queries/0_stateless/00740_optimize_predicate_expression.sql b/dbms/tests/queries/0_stateless/00740_optimize_predicate_expression.sql index 29d11b4d97d..b016ab49ddd 100644 --- a/dbms/tests/queries/0_stateless/00740_optimize_predicate_expression.sql +++ b/dbms/tests/queries/0_stateless/00740_optimize_predicate_expression.sql @@ -12,11 +12,11 @@ SELECT SELECT perf_1.site, perf_1.z AS z_1 FROM perf AS perf_1 WHERE user_id = 000 - ) ALL INNER JOIN ( + ) jss1 ALL INNER JOIN ( SELECT perf_2.site, perf_2.z AS z_2 FROM perf AS perf_2 WHERE user_id = 999 - ) USING site) as avg_values, + ) jss2 USING site) as avg_values, z_1 - avg_values.1 AS dif_1, z_2 - avg_values.2 AS dif_2, dif_1 * dif_2 AS mul, @@ -26,10 +26,10 @@ FROM ( SELECT perf_1.site, perf_1.z AS z_1 FROM perf AS perf_1 WHERE user_id = 000 -) ALL INNER JOIN ( +) js1 ALL INNER JOIN ( SELECT perf_2.site, perf_2.z AS z_2 FROM perf AS perf_2 WHERE user_id = 999 -) USING site); +) js2 USING site); DROP TABLE perf; diff --git a/dbms/tests/queries/0_stateless/00742_require_join_strictness.sql b/dbms/tests/queries/0_stateless/00742_require_join_strictness.sql index 63d81b653c5..958d349aa51 100644 --- a/dbms/tests/queries/0_stateless/00742_require_join_strictness.sql +++ b/dbms/tests/queries/0_stateless/00742_require_join_strictness.sql @@ -1,3 +1,3 @@ SET send_logs_level = 'none'; SET join_default_strictness = ''; -SELECT * FROM system.one INNER JOIN (SELECT number AS k FROM system.numbers) ON dummy = k; -- { serverError 417 } +SELECT * FROM system.one INNER JOIN (SELECT number AS k FROM system.numbers) js2 ON dummy = k; -- { serverError 417 } diff --git a/dbms/tests/queries/0_stateless/00744_join_not_found_column.sql b/dbms/tests/queries/0_stateless/00744_join_not_found_column.sql index 04b4c1f8563..a271347dcd9 100644 --- a/dbms/tests/queries/0_stateless/00744_join_not_found_column.sql +++ b/dbms/tests/queries/0_stateless/00744_join_not_found_column.sql @@ -19,7 +19,7 @@ FROM count(), 1 FROM test_00744 - ) USING (1) + ) jss2 USING (1) LIMIT 10 ); @@ -33,5 +33,5 @@ ALL INNER JOIN count(), 1 FROM test_00744 -) USING (1) +) js2 USING (1) LIMIT 10; diff --git a/dbms/tests/queries/0_stateless/00749_inner_join_of_unnamed_subqueries.sql b/dbms/tests/queries/0_stateless/00749_inner_join_of_unnamed_subqueries.sql index de43da698dc..a751b2e40f5 100644 --- a/dbms/tests/queries/0_stateless/00749_inner_join_of_unnamed_subqueries.sql +++ b/dbms/tests/queries/0_stateless/00749_inner_join_of_unnamed_subqueries.sql @@ -1,3 +1,5 @@ +set subquery_requires_alias = 0; + DROP TABLE IF EXISTS left_table; DROP TABLE IF EXISTS right_table; diff --git a/dbms/tests/queries/0_stateless/00779_all_right_join_max_block_size.sql b/dbms/tests/queries/0_stateless/00779_all_right_join_max_block_size.sql index 64a41d92a2f..f14b1393b3b 100644 --- a/dbms/tests/queries/0_stateless/00779_all_right_join_max_block_size.sql +++ b/dbms/tests/queries/0_stateless/00779_all_right_join_max_block_size.sql @@ -1,2 +1,2 @@ SET max_block_size = 6; -SELECT blockSize() bs FROM (SELECT 1 s) ALL RIGHT JOIN (SELECT arrayJoin([2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]) s) USING (s) GROUP BY bs ORDER BY bs; +SELECT blockSize() bs FROM (SELECT 1 s) js1 ALL RIGHT JOIN (SELECT arrayJoin([2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]) s) js2 USING (s) GROUP BY bs ORDER BY bs; diff --git a/dbms/tests/queries/0_stateless/00800_low_cardinality_join.sql b/dbms/tests/queries/0_stateless/00800_low_cardinality_join.sql index 9734b1ef31c..b938acf8c4e 100644 --- a/dbms/tests/queries/0_stateless/00800_low_cardinality_join.sql +++ b/dbms/tests/queries/0_stateless/00800_low_cardinality_join.sql @@ -1,3 +1,5 @@ +set subquery_requires_alias = 0; + select * from (select dummy as val from system.one) any left join (select dummy as val from system.one) using val; select * from (select toLowCardinality(dummy) as val from system.one) any left join (select dummy as val from system.one) using val; select * from (select dummy as val from system.one) any left join (select toLowCardinality(dummy) as val from system.one) using val; diff --git a/dbms/tests/queries/0_stateless/00804_test_delta_codec_compression.sql b/dbms/tests/queries/0_stateless/00804_test_delta_codec_compression.sql index 7c31d76c768..267af1b9c9f 100644 --- a/dbms/tests/queries/0_stateless/00804_test_delta_codec_compression.sql +++ b/dbms/tests/queries/0_stateless/00804_test_delta_codec_compression.sql @@ -1,4 +1,5 @@ SET send_logs_level = 'none'; +SET subquery_requires_alias = 0; DROP TABLE IF EXISTS delta_codec_synthetic; DROP TABLE IF EXISTS default_codec_synthetic; diff --git a/dbms/tests/queries/0_stateless/00819_full_join_wrong_columns_in_block.sql b/dbms/tests/queries/0_stateless/00819_full_join_wrong_columns_in_block.sql index 5666d362912..ac300978112 100644 --- a/dbms/tests/queries/0_stateless/00819_full_join_wrong_columns_in_block.sql +++ b/dbms/tests/queries/0_stateless/00819_full_join_wrong_columns_in_block.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT * FROM (SELECT 1 AS a, 'x' AS b) join (SELECT 1 as a, 'y' as b) using a; SELECT * FROM (SELECT 1 AS a, 'x' AS b) left join (SELECT 1 as a, 'y' as b) using a; diff --git a/dbms/tests/queries/0_stateless/00820_multiple_joins_subquery_requires_alias.reference b/dbms/tests/queries/0_stateless/00820_multiple_joins_subquery_requires_alias.reference new file mode 100644 index 00000000000..6d317230813 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00820_multiple_joins_subquery_requires_alias.reference @@ -0,0 +1,50 @@ +0 0 0 +6 60 600 +12 120 1200 +18 180 1800 +0 0 0 +10 100 1000 +20 200 2000 +┌─t1.a─┬─t2.a─┬─t2.b─┬─t3.b─┬─t3.c─┬─t5.a─┬─t5.b─┬─t5.c─┐ +│ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ +└──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘ +0 0 0 0 +6 6 60 60 +12 12 120 120 +18 18 180 180 +0 0 0 0 +6 6 60 60 +12 12 120 120 +18 18 180 180 +0 0 0 0 +6 6 60 60 +12 12 120 120 +18 18 180 180 +0 0 0 0 +6 6 60 60 +12 12 120 120 +18 18 180 180 +0 0 0 0 +6 6 60 60 +12 12 120 120 +18 18 180 180 +0 0 0 0 +6 6 60 60 +12 12 120 120 +18 18 180 180 +┌─t1.a─┬─t2.a─┬─t2.b─┬─t3.b─┬─t3.c─┐ +│ 0 │ 0 │ 0 │ 0 │ 0 │ +│ 6 │ 6 │ 60 │ 60 │ 600 │ +│ 12 │ 12 │ 120 │ 120 │ 1200 │ +│ 18 │ 18 │ 180 │ 180 │ 1800 │ +└──────┴──────┴──────┴──────┴──────┘ +┌─t1.a─┬─t2.a─┬─t2.b─┬─t3.b─┬─t3.c─┐ +│ 0 │ 0 │ 0 │ 0 │ 0 │ +│ 6 │ 6 │ 60 │ 60 │ 600 │ +│ 12 │ 12 │ 120 │ 120 │ 1200 │ +│ 18 │ 18 │ 180 │ 180 │ 1800 │ +└──────┴──────┴──────┴──────┴──────┘ +0 0 0 0 0 0 0 +6 6 60 60 66 66 120 +12 12 120 120 132 132 240 +18 18 180 180 198 198 360 diff --git a/dbms/tests/queries/0_stateless/00820_multiple_joins_subquery_requires_alias.sql b/dbms/tests/queries/0_stateless/00820_multiple_joins_subquery_requires_alias.sql new file mode 100644 index 00000000000..0bf1e03c9c0 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00820_multiple_joins_subquery_requires_alias.sql @@ -0,0 +1,85 @@ +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; +SET subquery_requires_alias = 1; + +select t1.a, t2.b, t3.c from table1 as t1 join table2 as t2 on t1.a = t2.a join table3 as t3 on t2.b = t3.b; +select t1.a, t2.b, t5.c from table1 as t1 join table2 as t2 on t1.a = t2.a join table5 as t5 on t1.a = t5.a AND t2.b = t5.b; + +select t1.a, t2.a, t2.b, t3.b, t3.c, t5.a, t5.b, t5.c +from table1 as t1 +join table2 as t2 on t1.a = t2.a +join table3 as t3 on t2.b = t3.b +join table5 as t5 on t3.c = t5.c +FORMAT PrettyCompactNoEscapes; + +select t1.a as t1_a, t2.a as t2_a, t2.b as t2_b, t3.b as t3_b +from table1 as t1 +join table2 as t2 on t1_a = t2_a +join table3 as t3 on t2_b = t3_b; + +select t1.a as t1_a, t2.a as t2_a, t2.b as t2_b, t3.b as t3_b +from table1 as t1 +join table2 as t2 on t1.a = t2.a +join table3 as t3 on t2.b = t3.b; + +select t1.a as t1_a, t2.a as t2_a, t2.b as t2_b, t3.b as t3_b +from table1 as t1 +join table2 as t2 on table1.a = table2.a +join table3 as t3 on table2.b = table3.b; + +select t1.a, t2.a, t2.b, t3.b +from table1 as t1 +join table2 as t2 on table1.a = table2.a +join table3 as t3 on table2.b = table3.b; + +select t1.a, t2.a, t2.b, t3.b +from table1 as t1 +join table2 as t2 on t1.a = t2.a +join table3 as t3 on t2.b = t3.b; + +select table1.a, table2.a, table2.b, table3.b +from table1 as t1 +join table2 as t2 on table1.a = table2.a +join table3 as t3 on table2.b = table3.b; + +select t1.*, t2.*, t3.* +from table1 as t1 +join table2 as t2 on table1.a = table2.a +join table3 as t3 on table2.b = table3.b +FORMAT PrettyCompactNoEscapes; + +select * +from table1 as t1 +join table2 as t2 on t1.a = t2.a +join table3 as t3 on t2.b = t3.b +FORMAT PrettyCompactNoEscapes; + +select t1.a as t1_a, t2.a as t2_a, t2.b as t2_b, t3.b as t3_b, + (t1.a + table2.b) as t1_t2_x, (table1.a + table3.b) as t1_t3_x, (t2.b + t3.b) as t2_t3_x +from table1 as t1 +join table2 as t2 on t1_a = t2_a +join table3 as t3 on t2_b = t3_b; + +--select (t1.a + table2.b) as t1_t2_x, (table1.a + table3.b) as t1_t3_x, (t2.b + t3.b) as t2_t3_x +--from table1 as t1 +--join table2 as t2 on t1_t2_x = t2.a +--join table3 as t3 on t1_t3_x = t2_t3_x; + +DROP TABLE table1; +DROP TABLE table2; +DROP TABLE table3; +DROP TABLE table5; diff --git a/dbms/tests/queries/0_stateless/00829_bitmap_function.sql b/dbms/tests/queries/0_stateless/00829_bitmap_function.sql index 247a9ba3960..bbe3e8f80fb 100644 --- a/dbms/tests/queries/0_stateless/00829_bitmap_function.sql +++ b/dbms/tests/queries/0_stateless/00829_bitmap_function.sql @@ -31,11 +31,11 @@ SELECT FROM ( SELECT city_id, groupBitmapState( uid ) AS day_today FROM bitmap_test WHERE pickup_date = '2019-01-02' GROUP BY city_id - ) +) js1 ALL LEFT JOIN ( SELECT city_id, groupBitmapState( uid ) AS day_before FROM bitmap_test WHERE pickup_date = '2019-01-01' GROUP BY city_id -) +) js2 USING city_id; SELECT @@ -48,11 +48,11 @@ SELECT FROM ( SELECT city_id, groupBitmapState( uid ) AS day_today FROM bitmap_test WHERE pickup_date = '2019-01-02' GROUP BY city_id - ) +) js1 ALL LEFT JOIN ( SELECT city_id, groupBitmapState( uid ) AS day_before FROM bitmap_test WHERE pickup_date = '2019-01-01' GROUP BY city_id -) +) js2 USING city_id; SELECT count(*) FROM bitmap_test WHERE bitmapHasAny((SELECT groupBitmapState(uid) FROM bitmap_test WHERE pickup_date = '2019-01-01'), bitmapBuild([uid])); diff --git a/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql b/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql index f2968654782..e02ef87f46d 100644 --- a/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql +++ b/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql @@ -1,9 +1,9 @@ SET any_join_distinct_right_table_keys = 1; -SELECT * FROM (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) -JOIN (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) +SELECT * FROM (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) js1 +JOIN (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) js2 USING (a, tup); -SELECT * FROM (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) -GLOBAL ANY FULL OUTER JOIN (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) +SELECT * FROM (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) js1 +GLOBAL ANY FULL OUTER JOIN (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) js2 USING (a, tup); diff --git a/dbms/tests/queries/0_stateless/00849_multiple_comma_join.sql b/dbms/tests/queries/0_stateless/00849_multiple_comma_join.sql index 08a64500f19..e1b3dc9b804 100644 --- a/dbms/tests/queries/0_stateless/00849_multiple_comma_join.sql +++ b/dbms/tests/queries/0_stateless/00849_multiple_comma_join.sql @@ -1,4 +1,5 @@ SET enable_debug_queries = 1; +SET subquery_requires_alias = 0; DROP TABLE IF EXISTS t1_00849; DROP TABLE IF EXISTS t2_00849; diff --git a/dbms/tests/queries/0_stateless/00850_global_join_dups.sql b/dbms/tests/queries/0_stateless/00850_global_join_dups.sql index ceb7a806056..052233420be 100644 --- a/dbms/tests/queries/0_stateless/00850_global_join_dups.sql +++ b/dbms/tests/queries/0_stateless/00850_global_join_dups.sql @@ -9,6 +9,7 @@ CREATE TABLE t2_00850 (dummy UInt8) ENGINE = Distributed(test_shard_localhost, c INSERT INTO t_local VALUES (1); SET asterisk_left_columns_only = 1; +SET subquery_requires_alias = 0; SELECT * FROM t1_00850 GLOBAL INNER JOIN diff --git a/dbms/tests/queries/0_stateless/00853_join_with_nulls_crash.sql b/dbms/tests/queries/0_stateless/00853_join_with_nulls_crash.sql index cbef2f709ac..4beba5a83f8 100644 --- a/dbms/tests/queries/0_stateless/00853_join_with_nulls_crash.sql +++ b/dbms/tests/queries/0_stateless/00853_join_with_nulls_crash.sql @@ -44,6 +44,8 @@ ALL RIGHT JOIN USING (something) ORDER BY count_a DESC; +SET subquery_requires_alias = 0; + SELECT something, count_a, count_b, toTypeName(something) FROM ( SELECT something, count() AS count_a FROM table_a GROUP BY something ) ALL FULL JOIN diff --git a/dbms/tests/queries/0_stateless/00855_join_with_array_join.sql b/dbms/tests/queries/0_stateless/00855_join_with_array_join.sql index 0ec79608326..8883691c501 100644 --- a/dbms/tests/queries/0_stateless/00855_join_with_array_join.sql +++ b/dbms/tests/queries/0_stateless/00855_join_with_array_join.sql @@ -1,3 +1,5 @@ +SET subquery_requires_alias = 0; + set allow_experimental_multiple_joins_emulation = 0; set allow_experimental_cross_to_join_conversion = 0; select ax, c from (select [1,2] ax, 0 c) array join ax join (select 0 c) using(c); diff --git a/dbms/tests/queries/0_stateless/00864_union_all_supertype.sql b/dbms/tests/queries/0_stateless/00864_union_all_supertype.sql index 67c5d53e3bf..03356aab2c0 100644 --- a/dbms/tests/queries/0_stateless/00864_union_all_supertype.sql +++ b/dbms/tests/queries/0_stateless/00864_union_all_supertype.sql @@ -1,3 +1,5 @@ +SET subquery_requires_alias = 0; + select toTypeName(key), toTypeName(value) from ( select 1 as key, '' as value union all diff --git a/dbms/tests/queries/0_stateless/00916_join_using_duplicate_columns.sql b/dbms/tests/queries/0_stateless/00916_join_using_duplicate_columns.sql index 22eeb2c51dc..c039d96480f 100644 --- a/dbms/tests/queries/0_stateless/00916_join_using_duplicate_columns.sql +++ b/dbms/tests/queries/0_stateless/00916_join_using_duplicate_columns.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT * FROM (SELECT 1 AS x) ALL LEFT JOIN (SELECT 1 AS x) USING x; SELECT * FROM (SELECT 1 AS x) ALL LEFT JOIN (SELECT 2 AS x) USING x; diff --git a/dbms/tests/queries/0_stateless/00917_multiple_joins_denny_crane.sql b/dbms/tests/queries/0_stateless/00917_multiple_joins_denny_crane.sql index f8da1ce7bed..2f056deb4c7 100644 --- a/dbms/tests/queries/0_stateless/00917_multiple_joins_denny_crane.sql +++ b/dbms/tests/queries/0_stateless/00917_multiple_joins_denny_crane.sql @@ -1,3 +1,5 @@ +SET subquery_requires_alias = 0; + DROP TABLE IF EXISTS ANIMAL; CREATE TABLE ANIMAL ( ANIMAL Nullable(String) ) engine = TinyLog; diff --git a/dbms/tests/queries/0_stateless/00956_join_use_nulls_with_array_column.sql b/dbms/tests/queries/0_stateless/00956_join_use_nulls_with_array_column.sql index 54741465a1d..244e04a564a 100644 --- a/dbms/tests/queries/0_stateless/00956_join_use_nulls_with_array_column.sql +++ b/dbms/tests/queries/0_stateless/00956_join_use_nulls_with_array_column.sql @@ -1,4 +1,4 @@ SET any_join_distinct_right_table_keys = 1; SET join_use_nulls = 1; -SELECT number FROM system.numbers ANY INNER JOIN (SELECT number, ['test'] FROM system.numbers LIMIT 1) USING (number) LIMIT 1; -SELECT number FROM system.numbers ANY LEFT JOIN (SELECT number, ['test'] FROM system.numbers LIMIT 1) USING (number) LIMIT 1; +SELECT number FROM system.numbers ANY INNER JOIN (SELECT number, ['test'] FROM system.numbers LIMIT 1) js2 USING (number) LIMIT 1; +SELECT number FROM system.numbers ANY LEFT JOIN (SELECT number, ['test'] FROM system.numbers LIMIT 1) js2 USING (number) LIMIT 1; diff --git a/dbms/tests/queries/0_stateless/01000_subquery_requires_alias.reference b/dbms/tests/queries/0_stateless/01000_subquery_requires_alias.reference new file mode 100644 index 00000000000..8018af28430 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01000_subquery_requires_alias.reference @@ -0,0 +1,2 @@ +1 2 3 +1 2 3 diff --git a/dbms/tests/queries/0_stateless/01000_subquery_requires_alias.sql b/dbms/tests/queries/0_stateless/01000_subquery_requires_alias.sql new file mode 100644 index 00000000000..fc874f98ccb --- /dev/null +++ b/dbms/tests/queries/0_stateless/01000_subquery_requires_alias.sql @@ -0,0 +1,19 @@ +SET subquery_requires_alias = 1; + +SELECT * FROM (SELECT 1 as A, 2 as B) X +ALL LEFT JOIN (SELECT 3 as A, 2 as B) Y +USING (B); + +SELECT * FROM (SELECT 1 as A, 2 as B) X +ALL LEFT JOIN (SELECT 3 as A, 2 as B) +USING (B); -- { serverError 206 } + +SELECT * FROM (SELECT 1 as A, 2 as B) +ALL LEFT JOIN (SELECT 3 as A, 2 as B) Y +USING (B); -- { serverError 206 } + +set subquery_requires_alias=0; + +SELECT * FROM (SELECT 1 as A, 2 as B) +ALL LEFT JOIN (SELECT 3 as A, 2 as B) Y +USING (B); diff --git a/dbms/tests/queries/1_stateful/00042_any_left_join.sql b/dbms/tests/queries/1_stateful/00042_any_left_join.sql index 3d94ddede37..16dc83c663e 100644 --- a/dbms/tests/queries/1_stateful/00042_any_left_join.sql +++ b/dbms/tests/queries/1_stateful/00042_any_left_join.sql @@ -18,4 +18,5 @@ FROM GROUP BY EventDate ) USING EventDate ORDER BY hits DESC -LIMIT 10; +LIMIT 10 +SETTINGS subquery_requires_alias = 0; diff --git a/dbms/tests/queries/1_stateful/00043_any_left_join.sql b/dbms/tests/queries/1_stateful/00043_any_left_join.sql index 495a776045f..2af9f412e6d 100644 --- a/dbms/tests/queries/1_stateful/00043_any_left_join.sql +++ b/dbms/tests/queries/1_stateful/00043_any_left_join.sql @@ -12,4 +12,5 @@ FROM test.hits ANY LEFT JOIN ) USING EventDate GROUP BY EventDate ORDER BY hits DESC -LIMIT 10; +LIMIT 10 +SETTINGS subquery_requires_alias = 0; diff --git a/dbms/tests/queries/1_stateful/00044_any_left_join_string.sql b/dbms/tests/queries/1_stateful/00044_any_left_join_string.sql index ce5236a2708..fdd35e4b151 100644 --- a/dbms/tests/queries/1_stateful/00044_any_left_join_string.sql +++ b/dbms/tests/queries/1_stateful/00044_any_left_join_string.sql @@ -19,3 +19,4 @@ FROM ) USING domain ORDER BY hits DESC LIMIT 10 +SETTINGS subquery_requires_alias = 0; diff --git a/dbms/tests/queries/1_stateful/00063_loyalty_joins.sql b/dbms/tests/queries/1_stateful/00063_loyalty_joins.sql index 9613d3b8f67..1cbcc9f7d0c 100644 --- a/dbms/tests/queries/1_stateful/00063_loyalty_joins.sql +++ b/dbms/tests/queries/1_stateful/00063_loyalty_joins.sql @@ -1,4 +1,5 @@ SET any_join_distinct_right_table_keys = 1; +SET subquery_requires_alias = 0; SELECT loyalty, diff --git a/dbms/tests/queries/1_stateful/00074_full_join.sql b/dbms/tests/queries/1_stateful/00074_full_join.sql index 4497d82a666..c05d342b2a1 100644 --- a/dbms/tests/queries/1_stateful/00074_full_join.sql +++ b/dbms/tests/queries/1_stateful/00074_full_join.sql @@ -1,4 +1,5 @@ set any_join_distinct_right_table_keys = 1; +set subquery_requires_alias = 0; SELECT CounterID,