```
2021.10.22 07:14:33.963099 [ 3451059 ] {} <Error> Application: DB::Exception: Syntax error (in file ./user_defined/function_a_function.sql): failed at position 39 ('->'): -> ch(2)

$ cat ./user_defined/function_a_function.sql
CREATE FUNCTION a_function AS tuple() -> ch(2)
```
{
    String res;
    if (tryGetFunctionNameInto(ast, res))
        return res;
    throw Exception(ast ? queryToString(*ast) + " is not an function" : "AST node is nullptr", ErrorCodes::UNEXPECTED_AST_STRUCTURE);
}
std::optional<String> tryGetFunctionName(const IAST * ast)
{
    String res;
    if (tryGetFunctionNameInto(ast, res))
        return res;
    return {};
}
bool tryGetFunctionNameInto(const IAST * ast, String & name)
{
    if (ast)
    {
        if (const auto * node = ast->as<ASTFunction>())
        {
            name = node->name;
            return true;
        }
    }
    return false;
}
}