mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Merge pull request #57102 from ClickHouse/vdimir/analyzer_to_ast_crash
Fix FunctionNode::toASTImpl
This commit is contained in:
commit
f138ddbdfa
@ -209,15 +209,17 @@ ASTPtr FunctionNode::toASTImpl(const ConvertToASTOptions & options) const
|
||||
function_ast->kind = ASTFunction::Kind::WINDOW_FUNCTION;
|
||||
}
|
||||
|
||||
const auto & arguments = getArguments();
|
||||
auto new_options = options;
|
||||
const auto & argument_nodes = arguments.getNodes();
|
||||
/// To avoid surrounding constants with several internal casts.
|
||||
if (function_name == "_CAST" && (*getArguments().begin())->getNodeType() == QueryTreeNodeType::CONSTANT)
|
||||
if (function_name == "_CAST" && !argument_nodes.empty() && argument_nodes[0]->getNodeType() == QueryTreeNodeType::CONSTANT)
|
||||
new_options.add_cast_for_constants = false;
|
||||
|
||||
/// Avoid cast for `IN tuple(...)` expression.
|
||||
/// Tuples colud be quite big, and adding a type may significantly increase query size.
|
||||
/// It should be safe because set type for `column IN tuple` is deduced from `column` type.
|
||||
if (isNameOfInFunction(function_name) && (*(++getArguments().begin()))->getNodeType() == QueryTreeNodeType::CONSTANT)
|
||||
if (isNameOfInFunction(function_name) && argument_nodes.size() > 1 && argument_nodes[1]->getNodeType() == QueryTreeNodeType::CONSTANT)
|
||||
new_options.add_cast_for_constants = false;
|
||||
|
||||
const auto & parameters = getParameters();
|
||||
@ -227,7 +229,6 @@ ASTPtr FunctionNode::toASTImpl(const ConvertToASTOptions & options) const
|
||||
function_ast->parameters = function_ast->children.back();
|
||||
}
|
||||
|
||||
const auto & arguments = getArguments();
|
||||
function_ast->children.push_back(arguments.toAST(new_options));
|
||||
function_ast->arguments = function_ast->children.back();
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
WITH
|
||||
x AS (SELECT in((SELECT * FROM y))),
|
||||
y AS (SELECT 1)
|
||||
SELECT * FROM x; -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
||||
|
Loading…
Reference in New Issue
Block a user