```
CREATE TABLE default.`01802_empsalary`
(
    `depname` LowCardinality(String),
    `empno` UInt64,
    `salary` Int32,
    `enroll_date` Date
)
ENGINE = MergeTree
ORDER BY enroll_date
SETTINGS index_granularity = 8192;
insert into 01802_empsalary values ('sales',1,5000,'2006-10-01'),('develop',8,6000,'2006-10-01'),('personnel',2,3900,'2006-12-23'),('develop',10,5200,'2007-08-01'),('sales',3,4800,'2007-08-01'),('sales',4,4801,'2007-08-08'),('develop',11,5200,'2007-08-15'),('personnel',5,3500,'2007-12-10'),('develop',7,4200,'2008-01-01'),('develop',9,4500,'2008-01-01');
```

Query hangs
```
SELECT rankCorr(salary, nan) OVER (ORDER BY salary ASC Rows BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS func
FROM `01802_empsalary
```

```
WITH arrayMap(x -> demangle(addressToSymbol(x)), trace) AS `all`
SELECT
    thread_name,
    thread_id,
    query_id,
    arrayStringConcat(`all`, '\n') AS res
FROM system.stack_trace
WHERE query_id = '41603474-6fdc-4790-bbed-53d919014ba5'

Query id: 9662b2c0-2a67-418c-8340-d3f19fea5c75

Row 1:
──────
thread_name: TCPHandler
thread_id:   21417
query_id:    41603474-6fdc-4790-bbed-53d919014ba5
res:
ConcurrentBoundedQueue<DB::Chunk>::popImpl(DB::Chunk&, std::__1::optional<unsigned long>)
DB::LazyOutputFormat::getChunk(unsigned long)
DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)
DB::PullingAsyncPipelineExecutor::pull(DB::Block&, unsigned long)
DB::TCPHandler::processOrdinaryQueryWithProcessors()
DB::TCPHandler::runImpl()
DB::TCPHandler::run()
Poco::Net::TCPServerConnection::start()
Poco::Net::TCPServerDispatcher::run()
Poco::PooledThread::run()
Poco::ThreadImpl::runnableEntry(void*)

__clone

Row 2:
──────
thread_name: QueryPullPipeEx
thread_id:   35307
query_id:    41603474-6fdc-4790-bbed-53d919014ba5
res:         std::__1::pair<std::__1::vector<double, std::__1::allocator<double> >, double> DB::computeRanksAndTieCorrection<DB::PODArray<double, 32ul, DB::MixedArenaAllocator<4096ul, Allocator<false, false>, DB::AlignedArenaAllocator<8ul>, 8ul>, 0ul, 0ul> >(DB::PODArray<double, 32ul, DB::MixedArenaAllocator<4096ul, Allocator<false, false>, DB::AlignedArenaAllocator<8ul>, 8ul>, 0ul, 0ul> const&)
DB::RankCorrelationData::getResult()
DB::AggregateFunctionRankCorrelation::insertResultInto(char*, DB::IColumn&, DB::Arena*) const
DB::WindowTransform::writeOutCurrentRow()
DB::WindowTransform::appendChunk(DB::Chunk&)
DB::WindowTransform::work()
DB::ExecutionThreadContext::executeTask()
DB::PipelineExecutor::executeStepImpl(unsigned long, std::__1::atomic<bool>*)
DB::PipelineExecutor::executeImpl(unsigned long)
DB::PipelineExecutor::execute(unsigned long)
void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'(), void ()> >(std::__1::__function::__policy_storage const*)
ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()> >(void*)

__clone

2 rows in set. Elapsed: 0.020 sec.
```
++right;
        auto adjusted = (left + right + 1.) / 2.;
        auto count_equal = right - left;
        
        if (count_equal == size)
            throw Exception("All numbers in both samples are identical", ErrorCodes::BAD_ARGUMENTS);
        tie_numenator += std::pow(count_equal, 3) - count_equal;
        for (size_t iter = left; iter < right; ++iter)
            out[indexes[iter]] = adjusted;
        left = right;
    }
    return {out, 1 - (tie_numenator / (std::pow(size, 3) - size))};
}
template <typename X, typename Y>
struct StatisticalSample
{
    using AllocatorXSample = MixedAlignedArenaAllocator<alignof(X), 4096>;
    using SampleX = PODArray<X, 32, AllocatorXSample>;
    using AllocatorYSample = MixedAlignedArenaAllocator<alignof(Y), 4096>;
    using SampleY = PODArray<Y, 32, AllocatorYSample>;
    SampleX x{};
    SampleY y{};
    size_t size_x{0};
    size_t size_y{0};
    void addX(X value, Arena * arena)
    {
        ++size_x;
        x.push_back(value, arena);
    }
    void addY(Y value, Arena * arena)