It hurts if server has millions of tables.

See https://github.com/ClickHouse/ClickHouse/pull/3398
Please add some tests to ensure it won't be broken in future.
auto ast = tryParseQuery(parser, pos, pos + query.size(), error_message,  false,
                             "in file " + metadata_file_path,  false, 0, settings.max_parser_depth);
    if (!ast && throw_on_error)
        throw Exception(error_message, ErrorCodes::SYNTAX_ERROR);
    else if (!ast)
        return nullptr;
    auto & create = ast->as<ASTCreateQuery &>();
    if (create.uuid != UUIDHelpers::Nil)
    {
        String table_name = Poco::Path(metadata_file_path).makeFile().getBaseName();
        table_name = unescapeForFileName(table_name);
        if (create.table != TABLE_WITH_UUID_NAME_PLACEHOLDER)
            LOG_WARNING(logger, "File {} contains both UUID and table name. Will use name `{}` instead of `{}`", metadata_file_path, table_name, create.table);
        create.table = table_name;
    }
    return ast;
}
ASTPtr DatabaseOnDisk::getCreateQueryFromMetadata(const String & database_metadata_path, bool throw_on_error) const
{
    ASTPtr ast = parseQueryFromMetadata(log, global_context, database_metadata_path, throw_on_error);
    if (ast)
    {
        auto & ast_create_query = ast->as<ASTCreateQuery &>();
        ast_create_query.attach = false;
        ast_create_query.database = database_name;
    }
    return ast;
}
}