**Describe the bug**
`SELECT i FROM generateRandom('i Array(Int8)', 1048575, 10, 1048577) LIMIT 1048575`

Memory limit should be respected.
ast = parseQuery(parser, begin, end, "", max_query_size, settings.max_parser_depth);
        auto * insert_query = ast->as<ASTInsertQuery>();
        if (insert_query && insert_query->settings_ast)
            InterpreterSetQuery(insert_query->settings_ast, context).executeForCurrentContext();
        if (insert_query && insert_query->data)
        {
            query_end = insert_query->data;
            insert_query->has_tail = has_query_tail;
        }
        else
        {
            query_end = end;
        }
    }
    catch (...)
    {
        
        String query = String(begin, begin + std::min(end - begin, static_cast<ptrdiff_t>(max_query_size)));
        auto query_for_logging = prepareQueryForLogging(query, context);
        logQuery(query_for_logging, context, internal);
        if (!internal)
        {
            onExceptionBeforeStart(query_for_logging, context, current_time, current_time_microseconds, ast);
        }
        throw;
    }
    setQuerySpecificSettings(ast, context);
    
    String query(begin, query_end);