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

Memory limit should be respected.
void write(const Block & block) override
    {
        if (!block)
            return;
        
        metadata_snapshot->check(block, true);
        size_t rows = block.rows();
        if (!rows)
            return;
        StoragePtr destination;
        if (storage.destination_id)
        {
            destination = DatabaseCatalog::instance().tryGetTable(storage.destination_id, storage.global_context);
            if (destination.get() == &storage)
                throw Exception("Destination table is myself. Write will cause infinite loop.", ErrorCodes::INFINITE_LOOP);
        }
        size_t bytes = block.bytes();
        storage.writes.rows += rows;
        storage.writes.bytes += bytes;
        
        if (rows > storage.max_thresholds.rows || bytes > storage.max_thresholds.bytes)
        {
            if (storage.destination_id)
            {
                LOG_TRACE(storage.log, "Writing block with {} rows, {} bytes directly.", rows, bytes);
                storage.writeBlockToDestination(block, destination);
            }