Merge pull request #43572 from kitaisreal/analyzer-table-functions-untuple-fix

Analyzer table functions untuple fix
This commit is contained in:
Maksim Kita 2022-11-24 11:28:56 +03:00 committed by GitHub
commit 9b935694ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 19 deletions

View File

@ -5455,25 +5455,7 @@ void QueryAnalyzer::resolveQueryJoinTreeNode(QueryTreeNodePtr & join_tree_node,
}
}
/// TODO: Special functions that can take query
/// TODO: Support qualified matchers for table function
for (auto & argument_node : table_function_node.getArguments().getNodes())
{
if (argument_node->getNodeType() == QueryTreeNodeType::MATCHER)
{
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Matcher as table function argument is not supported {}. In scope {}",
join_tree_node->formatASTForErrorMessage(),
scope.scope_node->formatASTForErrorMessage());
}
auto * function_node = argument_node->as<FunctionNode>();
if (function_node && table_function_factory.hasNameOrAlias(function_node->getFunctionName()))
continue;
resolveExpressionNode(argument_node, scope, false /*allow_lambda_expression*/, true /*allow_table_expression*/);
}
resolveExpressionNodeList(table_function_node.getArgumentsNode(), scope, false /*allow_lambda_expression*/, true /*allow_table_expression*/);
auto table_function_ast = table_function_node.toAST();
table_function_ptr->parseArguments(table_function_ast, scope_context);

View File

@ -0,0 +1,28 @@
0
--
0
1
--
1
2
--
(1) 0
--
(0,1) 0
--
(1,2) 1
(1,2) 2
--
(1) 0
--
(0,1) 0
--
(1,2) 1
(1,2) 2
--
('1') 0
--
('0','1') 0
--
('1','2') 1
('1','2') 2

View File

@ -0,0 +1,47 @@
SET allow_experimental_analyzer = 1;
SELECT number FROM numbers(untuple(tuple(1)));
SELECT '--';
SELECT number FROM numbers(untuple(tuple(0, 2)));
SELECT '--';
SELECT number FROM numbers(untuple(tuple(1, 2)));
SELECT '--';
SELECT cast(tuple(1), 'Tuple(value UInt64)') AS value, number FROM numbers(untuple(value));
SELECT '--';
SELECT cast(tuple(0, 1), 'Tuple(value_1 UInt64, value_2 UInt64)') AS value, number FROM numbers(untuple(value));
SELECT '--';
SELECT cast(tuple(1, 2), 'Tuple(value_1 UInt64, value_2 UInt64)') AS value, number FROM numbers(untuple(value));
SELECT '--';
SELECT cast(tuple(1), 'Tuple(value UInt64)') AS value, number FROM numbers(value.*);
SELECT '--';
SELECT cast(tuple(0, 1), 'Tuple(value_1 UInt64, value_2 UInt64)') AS value, number FROM numbers(value.*);
SELECT '--';
SELECT cast(tuple(1, 2), 'Tuple(value_1 UInt64, value_2 UInt64)') AS value, number FROM numbers(value.*);
SELECT '--';
SELECT cast(tuple('1'), 'Tuple(value String)') AS value, number FROM numbers(value.* APPLY x -> toUInt64(x));
SELECT '--';
SELECT cast(tuple('0', '1'), 'Tuple(value_1 String, value_2 String)') AS value, number FROM numbers(value.* APPLY x -> toUInt64(x));
SELECT '--';
SELECT cast(tuple('1', '2'), 'Tuple(value_1 String, value_2 String)') AS value, number FROM numbers(value.* APPLY x -> toUInt64(x));