Replace parameters in ASTFunctions with alias.

This commit is contained in:
abel-wang 2021-08-10 23:22:33 +08:00
parent 476b066668
commit ec0ee2cecf

View File

@ -256,6 +256,9 @@ void QueryNormalizer::visit(ASTPtr & ast, Data & data)
visit(*node_select, ast, data); visit(*node_select, ast, data);
else if (auto * node_param = ast->as<ASTQueryParameter>()) else if (auto * node_param = ast->as<ASTQueryParameter>())
throw Exception("Query parameter " + backQuote(node_param->name) + " was not set", ErrorCodes::UNKNOWN_QUERY_PARAMETER); throw Exception("Query parameter " + backQuote(node_param->name) + " was not set", ErrorCodes::UNKNOWN_QUERY_PARAMETER);
else if (auto * node_function = ast->as<ASTFunction>())
if (node_function->parameters)
visit(node_function->parameters, data);
/// If we replace the root of the subtree, we will be called again for the new root, in case the alias is replaced by an alias. /// If we replace the root of the subtree, we will be called again for the new root, in case the alias is replaced by an alias.
if (ast.get() != initial_ast.get()) if (ast.get() != initial_ast.get())