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

Memory limit should be respected.
{
    return std::make_shared<BufferBlockOutputStream>(*this, metadata_snapshot);
}
bool StorageBuffer::mayBenefitFromIndexForIn(
    const ASTPtr & left_in_operand, const Context & query_context, const StorageMetadataPtr & ) const
{
    if (!destination_id)
        return false;
    auto destination = DatabaseCatalog::instance().getTable(destination_id, query_context);
    if (destination.get() == this)
        throw Exception("Destination table is myself. Read will cause infinite loop.", ErrorCodes::INFINITE_LOOP);
    return destination->mayBenefitFromIndexForIn(left_in_operand, query_context, destination->getInMemoryMetadataPtr());
}
void StorageBuffer::startup()
{
    if (global_context.getSettingsRef().readonly)
    {
        LOG_WARNING(log, "Storage {} is run with readonly settings, it will not be able to insert data. Set appropriate system_profile to fix this.", getName());
    }
    flush_handle = bg_pool.createTask(log->name() + "/Bg", [this]{ flushBack(); });
    flush_handle->activateAndSchedule();
}
void StorageBuffer::shutdown()