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

Memory limit should be respected.
#include <Storages/MergeTree/MergeTreeDataPartWriterOnDisk.h>
#include <utility>
namespace DB
{
namespace ErrorCodes
{
    extern const int LOGICAL_ERROR;
}
namespace
{
    constexpr auto INDEX_FILE_EXTENSION = ".idx";
}
void MergeTreeDataPartWriterOnDisk::Stream::finalize()
{
    compressed.next();
    
    plain_hashing.next();
    marks.next();
    plain_file->finalize();
    marks_file->finalize();
}
void MergeTreeDataPartWriterOnDisk::Stream::sync() const
{
    plain_file->sync();
    marks_file->sync();
}
MergeTreeDataPartWriterOnDisk::Stream::Stream(