mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
SQLUserDefinedFunctions composition fix
This commit is contained in:
parent
4ad679946b
commit
650a79a907
@ -18,7 +18,7 @@ namespace ErrorCodes
|
|||||||
extern const int UNSUPPORTED_METHOD;
|
extern const int UNSUPPORTED_METHOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserDefinedSQLFunctionMatcher::visit(ASTPtr & ast, Data &)
|
void UserDefinedSQLFunctionMatcher::visit(ASTPtr & ast, Data & data)
|
||||||
{
|
{
|
||||||
auto * function = ast->as<ASTFunction>();
|
auto * function = ast->as<ASTFunction>();
|
||||||
if (!function)
|
if (!function)
|
||||||
@ -27,7 +27,10 @@ void UserDefinedSQLFunctionMatcher::visit(ASTPtr & ast, Data &)
|
|||||||
auto result = tryToReplaceFunction(*function);
|
auto result = tryToReplaceFunction(*function);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
|
{
|
||||||
ast = result;
|
ast = result;
|
||||||
|
visit(ast, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserDefinedSQLFunctionMatcher::needChildVisit(const ASTPtr &, const ASTPtr &)
|
bool UserDefinedSQLFunctionMatcher::needChildVisit(const ASTPtr &, const ASTPtr &)
|
||||||
|
@ -440,6 +440,7 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format
|
|||||||
|
|
||||||
if (!written && 0 == strcmp(name.c_str(), "lambda"))
|
if (!written && 0 == strcmp(name.c_str(), "lambda"))
|
||||||
{
|
{
|
||||||
|
/// Special case: zero elements tuple in lhs of lambda is printed as ().
|
||||||
/// Special case: one-element tuple in lhs of lambda is printed as its element.
|
/// Special case: one-element tuple in lhs of lambda is printed as its element.
|
||||||
|
|
||||||
if (frame.need_parens)
|
if (frame.need_parens)
|
||||||
@ -449,9 +450,12 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format
|
|||||||
if (first_arg_func
|
if (first_arg_func
|
||||||
&& first_arg_func->name == "tuple"
|
&& first_arg_func->name == "tuple"
|
||||||
&& first_arg_func->arguments
|
&& first_arg_func->arguments
|
||||||
&& first_arg_func->arguments->children.size() == 1)
|
&& (first_arg_func->arguments->children.size() == 1 || first_arg_func->arguments->children.size() == 0))
|
||||||
{
|
{
|
||||||
first_arg_func->arguments->children[0]->formatImpl(settings, state, nested_need_parens);
|
if (first_arg_func->arguments->children.size() == 1)
|
||||||
|
first_arg_func->arguments->children[0]->formatImpl(settings, state, nested_need_parens);
|
||||||
|
else
|
||||||
|
settings.ostr << "()";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
arguments->children[0]->formatImpl(settings, state, nested_need_parens);
|
arguments->children[0]->formatImpl(settings, state, nested_need_parens);
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
2
|
||||||
|
2
|
@ -0,0 +1,12 @@
|
|||||||
|
-- Tags: no-parallel
|
||||||
|
|
||||||
|
CREATE FUNCTION 02103_test_function AS x -> x + 1;
|
||||||
|
CREATE FUNCTION 02103_test_function_with_nested_function_empty_args AS () -> 02103_test_function(1);
|
||||||
|
CREATE FUNCTION 02103_test_function_with_nested_function_arg AS (x) -> 02103_test_function(x);
|
||||||
|
|
||||||
|
SELECT 02103_test_function_with_nested_function_empty_args();
|
||||||
|
SELECT 02103_test_function_with_nested_function_arg(1);
|
||||||
|
|
||||||
|
DROP FUNCTION 02103_test_function_with_nested_function_empty_args;
|
||||||
|
DROP FUNCTION 02103_test_function_with_nested_function_arg;
|
||||||
|
DROP FUNCTION 02103_test_function;
|
Loading…
Reference in New Issue
Block a user