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

Memory limit should be respected.
if (query_for_logging.empty())
                query_for_logging = prepareQueryForLogging(query, context);
            onExceptionBeforeStart(query_for_logging, context, current_time, current_time_microseconds, ast);
        }
        throw;
    }
    return std::make_tuple(ast, std::move(res));
}
BlockIO executeQuery(
    const String & query,
    Context & context,
    bool internal,
    QueryProcessingStage::Enum stage,
    bool may_have_embedded_data)
{
    ASTPtr ast;
    BlockIO streams;
    std::tie(ast, streams) = executeQueryImpl(query.data(), query.data() + query.size(), context,
        internal, stage, !may_have_embedded_data, nullptr);
    if (const auto * ast_query_with_output = dynamic_cast<const ASTQueryWithOutput *>(ast.get()))
    {
        String format_name = ast_query_with_output->format
                ? getIdentifierName(ast_query_with_output->format)
                : context.getDefaultFormat();
        if (format_name == "Null")
            streams.null_format = true;
    }
    return streams;
}
BlockIO executeQuery(