Updated tests

This commit is contained in:
Maksim Kita 2022-11-08 18:25:13 +01:00
parent 3b3e27f22a
commit e0f1fd93f3
4 changed files with 375 additions and 114 deletions

View File

@ -2136,8 +2136,8 @@ QueryTreeNodePtr QueryAnalyzer::tryResolveIdentifierFromTableExpression(const Id
if (qualified_identifier_with_removed_part.empty())
break;
if (scope.context->getSettingsRef().prefer_column_name_to_alias
&& scope.alias_name_to_expression_node.contains(qualified_identifier_with_removed_part[0]))
IdentifierLookup bind_to_aliases_identifier_lookup = {qualified_identifier_with_removed_part, IdentifierLookupContext::EXPRESSION};
if (tryBindIdentifierToAliases(bind_to_aliases_identifier_lookup, scope))
break;
bool can_remove_qualificator = true;
@ -2333,39 +2333,45 @@ QueryTreeNodePtr QueryAnalyzer::tryResolveIdentifierFromArrayJoin(const Identifi
if (scope.table_expressions_in_resolve_process.contains(table_expression_node.get()))
return resolved_identifier;
for (const auto & array_join_expression : from_array_join_node.getJoinExpressions().getNodes())
const auto & array_join_column_expressions = from_array_join_node.getJoinExpressions();
const auto & array_join_column_expressions_nodes = array_join_column_expressions.getNodes();
/** Allow JOIN with USING with ARRAY JOIN.
*
* SELECT * FROM test_table_1 AS t1 ARRAY JOIN [1,2,3] AS id INNER JOIN test_table_2 AS t2 ON t1.id = t2.id
* SELECT * FROM test_table_1 AS t1 ARRAY JOIN t1.id AS id INNER JOIN test_table_2 AS t2 ON t1.id = t2.id
*/
for (const auto & array_join_column_expression : array_join_column_expressions_nodes)
{
/** Allow JOIN with USING with ARRAY JOIN.
*
* SELECT * FROM test_table_1 AS t1 ARRAY JOIN [1,2,3] AS id INNER JOIN test_table_2 AS t2 ON t1.id = t2.id
* SELECT * FROM test_table_1 AS t1 ARRAY JOIN t1.id AS id INNER JOIN test_table_2 AS t2 ON t1.id = t2.id
*/
auto & array_join_column_expression_typed = array_join_column_expression->as<ColumnNode &>();
if (identifier_lookup.identifier.isShort() &&
array_join_expression->getAlias() == identifier_lookup.identifier.getFullName())
{
resolved_identifier = array_join_expression;
break;
}
array_join_column_expression_typed.getAlias() == identifier_lookup.identifier.getFullName())
return array_join_column_expression;
}
if (!resolved_identifier)
if (!resolved_identifier)
return nullptr;
/** Special case when qualified or unqualified identifier point to array join expression without alias.
*
* CREATE TABLE test_table (id UInt64, value String, value_array Array(UInt8)) ENGINE=TinyLog;
* SELECT id, value, value_array, test_table.value_array, default.test_table.value_array FROM test_table ARRAY JOIN value_array;
*
* value_array, test_table.value_array, default.test_table.value_array must be resolved into array join expression.
*/
for (const auto & array_join_column_expression : array_join_column_expressions_nodes)
{
auto & array_join_column_expression_typed = array_join_column_expression->as<ColumnNode &>();
if (array_join_column_expression_typed.hasAlias())
continue;
/** Special case when qualified or unqualified identifier point to array join expression without alias.
*
* CREATE TABLE test_table (id UInt64, value String, value_array Array(UInt8)) ENGINE=TinyLog;
* SELECT id, value, value_array, test_table.value_array, default.test_table.value_array FROM test_table ARRAY JOIN value_array;
*
* value_array, test_table.value_array, default.test_table.value_array must be resolved into array join expression.
*/
auto & array_join_column_expression = array_join_expression->as<ColumnNode &>();
if (array_join_column_expression.hasAlias())
continue;
auto & array_join_column_inner_expression = array_join_column_expression.getExpressionOrThrow();
auto & array_join_column_inner_expression = array_join_column_expression_typed.getExpressionOrThrow();
if (array_join_column_inner_expression.get() == resolved_identifier.get() ||
array_join_column_inner_expression->isEqual(*resolved_identifier))
{
resolved_identifier = array_join_expression;
resolved_identifier = array_join_column_expression;
break;
}
}
@ -2889,7 +2895,48 @@ QueryAnalyzer::QueryTreeNodesWithNames QueryAnalyzer::resolveUnqualifiedMatcher(
QueryTreeNodesWithNames matched_expression_nodes_with_column_names;
if (auto * array_join_node = table_expression->as<ArrayJoinNode>())
{
size_t table_expressions_column_nodes_with_names_stack_size = table_expressions_column_nodes_with_names_stack.size();
if (table_expressions_column_nodes_with_names_stack_size < 1)
throw Exception(ErrorCodes::LOGICAL_ERROR,
"Expected at least 1 table expressions on stack before ARRAY JOIN processing. Actual {}",
table_expressions_column_nodes_with_names_stack_size);
auto & table_expression_column_nodes_with_names = table_expressions_column_nodes_with_names_stack.back();
const auto & array_join_column_list = array_join_node->getJoinExpressions();
const auto & array_join_column_nodes = array_join_column_list.getNodes();
/** Special case with ARRAY JOIN column without alias.
*
* CREATE TABLE test_table (id UInt64, value String, value_array Array(UInt8)) ENGINE=TinyLog;
* SELECT * FROM test_table ARRAY JOIN value_array;
*
* In matched columns `value_array` must be resolved into array join column.
*/
for (const auto & array_join_column_node : array_join_column_nodes)
{
if (array_join_column_node->hasAlias())
continue;
auto array_join_column_inner_expression = array_join_column_node->as<ColumnNode &>().getExpressionOrThrow();
if (array_join_column_inner_expression->getNodeType() != QueryTreeNodeType::COLUMN)
continue;
for (auto & table_expressions_column_node_with_name : table_expression_column_nodes_with_names)
{
auto & table_expression_column_node = table_expressions_column_node_with_name.first;
if (table_expression_column_node.get() == array_join_column_inner_expression.get() ||
table_expression_column_node->isEqual(*array_join_column_inner_expression))
{
table_expression_column_node = array_join_column_node;
}
}
}
continue;
}
bool table_expression_in_resolve_process = scope.table_expressions_in_resolve_process.contains(table_expression.get());
@ -2947,28 +2994,19 @@ QueryAnalyzer::QueryTreeNodesWithNames QueryAnalyzer::resolveUnqualifiedMatcher(
* In such example, match `id` column from ARRAY JOIN, and all columns from test_table except `id`.
*
* SELECT * FROM (SELECT [0] AS id) AS t1 ARRAY JOIN id AS id INNER JOIN test_table USING (id);
* In such example match `id` column from ARRAY JOIN, and all columns from test_table except `id`.
* In such example match `id` column from t1, and all columns from test_table except `id`.
*
* SELECT * FROM (SELECT [0] AS id) AS t1 ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
* In such example match `id` column from t1, and all columns from test_table except `id`.
*/
auto & matched_column_node_typed = matched_column_node->as<ColumnNode &>();
auto matched_column_source = matched_column_node->as<ColumnNode &>().getColumnSource();
if (matched_column_source->getNodeType() == QueryTreeNodeType::ARRAY_JOIN)
if (matched_column_source->getNodeType() == QueryTreeNodeType::ARRAY_JOIN && matched_column_node->hasAlias())
{
auto * array_join_inner_expression_column = matched_column_node_typed.getExpressionOrThrow()->as<ColumnNode>();
if (array_join_inner_expression_column && array_join_inner_expression_column->getColumnName() == using_column_name)
{
if (isRight(join_node->getKind()))
left_table_expression_column_names_to_skip.insert(using_column_name);
right_table_expression_column_names_to_skip.insert(using_column_name);
matched_expression_nodes_with_column_names.emplace_back(std::move(matched_column_node), using_column_name);
}
else
{
right_table_expression_column_names_to_skip.insert(using_column_name);
}
}
else
{
@ -5028,6 +5066,8 @@ void QueryAnalyzer::resolveQueryJoinTreeNode(QueryTreeNodePtr & join_tree_node,
resolveQueryJoinTreeNode(array_join_node.getTableExpression(), scope, expressions_visitor);
validateJoinTableExpressionWithoutAlias(join_tree_node, array_join_node.getTableExpression(), scope);
std::unordered_set<String> array_join_column_names;
/// Wrap array join expressions into column nodes, where array join expression is inner expression.
for (auto & array_join_expression : array_join_node.getJoinExpressions().getNodes())
@ -5056,16 +5096,37 @@ void QueryAnalyzer::resolveQueryJoinTreeNode(QueryTreeNodePtr & join_tree_node,
result_type = assert_cast<const DataTypeArray &>(*result_type).getNestedType();
auto array_join_expression_name = "__array_join_expression_" + std::to_string(array_join_expressions_counter);
++array_join_expressions_counter;
String array_join_column_name;
auto array_join_column = std::make_shared<ColumnNode>(NameAndTypePair{array_join_expression_name, result_type}, array_join_expression, join_tree_node);
if (!array_join_expression_alias.empty())
{
array_join_column_name = array_join_expression_alias;
}
else if (auto * array_join_expression_inner_column = array_join_expression->as<ColumnNode>())
{
array_join_column_name = array_join_expression_inner_column->getColumnName();
}
else
{
array_join_column_name = "__array_join_expression_" + std::to_string(array_join_expressions_counter);
++array_join_expressions_counter;
}
if (array_join_column_names.contains(array_join_column_name))
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"ARRAY JOIN {} multiple columns with name {}. In scope {}",
array_join_node.formatASTForErrorMessage(),
array_join_column_name,
scope.scope_node->formatASTForErrorMessage());
array_join_column_names.emplace(array_join_column_name);
auto array_join_column = std::make_shared<ColumnNode>(NameAndTypePair{array_join_column_name, result_type}, array_join_expression, join_tree_node);
array_join_expression = std::move(array_join_column);
array_join_expression->setAlias(array_join_expression_alias);
auto it = scope.alias_name_to_expression_node.find(array_join_expression_alias);
if (it != scope.alias_name_to_expression_node.end())
it->second = std::make_shared<ColumnNode>(NameAndTypePair{array_join_expression_name, result_type}, join_tree_node);
it->second = array_join_expression;
}
break;

View File

@ -1,71 +0,0 @@
SET allow_experimental_analyzer = 1;
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
id UInt64,
value String
) ENGINE=MergeTree ORDER BY id;
INSERT INTO test_table VALUES (0, 'Value_0');
INSERT INTO test_table VALUES (1, 'Value_1');
SELECT * FROM (SELECT [dummy, dummy] AS dummy FROM system.one) AS subquery ARRAY JOIN dummy INNER JOIN system.one USING (dummy);
SELECT '--';
SELECT * FROM (SELECT [0] AS dummy) AS subquery_1 ARRAY JOIN dummy INNER JOIN system.one USING (dummy);
SELECT '--';
SELECT * FROM (SELECT [1] AS dummy) AS subquery_1 ARRAY JOIN dummy INNER JOIN system.one USING (dummy);
SELECT '--';
SELECT * FROM (SELECT [0] AS dummy) AS subquery_1 ARRAY JOIN dummy INNER JOIN (SELECT 1 AS dummy) AS subquery_2 USING (dummy);
SELECT '--';
SELECT * FROM (SELECT [1] AS dummy) AS subquery_1 ARRAY JOIN dummy INNER JOIN (SELECT 1 AS dummy) AS subquery_2 USING (dummy);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS id) AS subquery_1 ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS value) AS subquery_1 ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS value) AS subquery_1 ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [5] AS id) AS subquery_1 ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [5] AS id) AS subquery_1 ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
DROP TABLE test_table;

View File

@ -0,0 +1,128 @@
-- { echoOn }
SELECT * FROM test_table ARRAY JOIN value_array;
0 Value_0 1
0 Value_0 2
0 Value_0 3
SELECT '--';
--
SELECT *, value_array_element FROM test_table ARRAY JOIN value_array AS value_array_element;
0 Value_0 [1,2,3] 1
0 Value_0 [1,2,3] 2
0 Value_0 [1,2,3] 3
SELECT '--';
--
SELECT *, value_array FROM test_table ARRAY JOIN value_array AS value_array;
0 Value_0 [1,2,3] 1
0 Value_0 [1,2,3] 2
0 Value_0 [1,2,3] 3
SELECT '--';
--
SELECT *, value_array FROM test_table ARRAY JOIN [4,5,6] AS value_array;
0 Value_0 [1,2,3] 4
0 Value_0 [1,2,3] 5
0 Value_0 [1,2,3] 6
SELECT '--';
--
SELECT *, value_array, value_element FROM test_table ARRAY JOIN value_array, [4,5,6] AS value_element;
0 Value_0 1 1 4
0 Value_0 2 2 5
0 Value_0 3 3 6
SELECT '--';
--
SELECT * FROM (SELECT [dummy, dummy] AS dummy FROM system.one) AS subquery ARRAY JOIN dummy INNER JOIN system.one USING (dummy);
0
0
SELECT '--';
--
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 0 AS id) AS subquery_2 USING (id);
0
SELECT '--';
--
SELECT * FROM (SELECT [1] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 0 AS id) AS subquery_2 USING (id);
SELECT '--';
--
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 1 AS id) AS subquery_2 USING (id);
SELECT '--';
--
SELECT * FROM (SELECT [1] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 1 AS id) AS subquery_2 USING (id);
1
SELECT '--';
--
SELECT * FROM (SELECT [5] AS id) AS subquery_1 ARRAY JOIN [1,2,3] AS id INNER JOIN (SELECT 1 AS id) AS subquery_2 USING (id);
[5]
SELECT '--';
--
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN id INNER JOIN test_table USING (id);
0 Value_0 [1,2,3]
SELECT '--';
--
SELECT * FROM (SELECT [1] AS id) AS subquery ARRAY JOIN id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
[0] Value_0 [1,2,3]
SELECT '--';
--
SELECT * FROM (SELECT [1] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT *, id FROM (SELECT [0] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
[0] Value_0 [1,2,3] 0
SELECT '--';
--
SELECT *, id FROM (SELECT [1] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT * FROM (SELECT [0] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
[0] Value_0 [1,2,3]
SELECT '--';
--
SELECT * FROM (SELECT [1] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT *, id FROM (SELECT [0] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
[0] Value_0 [1,2,3] 0
SELECT '--';
--
SELECT *, id FROM (SELECT [1] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
[0] Value_0 [1,2,3]
SELECT '--';
--
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT *, id FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
[0] Value_0 [1,2,3] 0
SELECT '--';
--
SELECT *, id FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT * FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
[5] Value_0 [1,2,3]
SELECT '--';
--
SELECT * FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT *, id FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
[5] Value_0 [1,2,3] 0
SELECT '--';
--
SELECT *, id FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
--
SELECT * FROM (SELECT [5] AS id_array) AS subquery ARRAY JOIN id_array, [0] AS id INNER JOIN test_table USING (id);
5 Value_0 [1,2,3]
SELECT '--';
--
SELECT * FROM (SELECT [[0]] AS id) AS subquery ARRAY JOIN id AS id_nested_array ARRAY JOIN id_nested_array AS id INNER JOIN test_table USING (id);
[[0]] Value_0 [1,2,3]
SELECT '--';
--
SELECT *, id FROM (SELECT [[0]] AS id) AS subquery ARRAY JOIN id AS id_nested_array ARRAY JOIN id_nested_array AS id INNER JOIN test_table USING (id);
[[0]] Value_0 [1,2,3] 0

View File

@ -0,0 +1,143 @@
SET allow_experimental_analyzer = 1;
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
id UInt64,
value String,
value_array Array(UInt64)
) ENGINE=MergeTree ORDER BY id;
INSERT INTO test_table VALUES (0, 'Value_0', [1,2,3]);
-- { echoOn }
SELECT * FROM test_table ARRAY JOIN value_array;
SELECT '--';
SELECT *, value_array_element FROM test_table ARRAY JOIN value_array AS value_array_element;
SELECT '--';
SELECT *, value_array FROM test_table ARRAY JOIN value_array AS value_array;
SELECT '--';
SELECT *, value_array FROM test_table ARRAY JOIN [4,5,6] AS value_array;
SELECT '--';
SELECT *, value_array, value_element FROM test_table ARRAY JOIN value_array, [4,5,6] AS value_element;
SELECT '--';
SELECT * FROM (SELECT [dummy, dummy] AS dummy FROM system.one) AS subquery ARRAY JOIN dummy INNER JOIN system.one USING (dummy);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 0 AS id) AS subquery_2 USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 0 AS id) AS subquery_2 USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 1 AS id) AS subquery_2 USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS id) AS subquery_1 ARRAY JOIN id INNER JOIN (SELECT 1 AS id) AS subquery_2 USING (id);
SELECT '--';
SELECT * FROM (SELECT [5] AS id) AS subquery_1 ARRAY JOIN [1,2,3] AS id INNER JOIN (SELECT 1 AS id) AS subquery_2 USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS id) AS subquery ARRAY JOIN id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [0] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [1] AS id) AS subquery ARRAY JOIN id AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [1] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [0] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [1] AS value) AS subquery ARRAY JOIN value AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [0] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [0] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [5] AS id) AS subquery ARRAY JOIN [1] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [5] AS id_array) AS subquery ARRAY JOIN id_array, [0] AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT * FROM (SELECT [[0]] AS id) AS subquery ARRAY JOIN id AS id_nested_array ARRAY JOIN id_nested_array AS id INNER JOIN test_table USING (id);
SELECT '--';
SELECT *, id FROM (SELECT [[0]] AS id) AS subquery ARRAY JOIN id AS id_nested_array ARRAY JOIN id_nested_array AS id INNER JOIN test_table USING (id);
-- { echoOff }
DROP TABLE test_table;