**Describe the bug**

Build the server in debug mode.

```
CREATE TABLE alias10__fuzz_13 (`Id` Array(Array(UInt256)), `EventDate` Array(String), `field1` Array(Array(Nullable(Int8))), `field2` Array(Date), `field3` Array(Array(Array(UInt128)))) ENGINE = Distributed(test_shard_localhost, currentDatabase(), alias_local10);

set allow_deprecated_syntax_for_merge_tree=1;
CREATE TABLE alias_local10 (
  Id Int8,
  EventDate Date DEFAULT '2000-01-01',
  field1 Int8,
  field2 String,
  field3 ALIAS CASE WHEN field1 = 1 THEN field2 ELSE '0' END
) ENGINE = MergeTree(EventDate, (Id, EventDate), 8192);

SET prefer_localhost_replica = 0;

SELECT field1 FROM alias10__fuzz_13 WHERE arrayEnumerateDense(NULL, tuple('0.2147483646'), NULL) GROUP BY field1, arrayEnumerateDense(('0.02', '0.1', '0'), NULL) WITH TOTALS;
```

https://s3.amazonaws.com/clickhouse-test-reports/0/e7df1f7113414a532f66a9de8b0e4c205efabe76/fuzzer_astfuzzerubsan/report.html

```
2022.12.30 12:08:53.266010 [ 956786 ] {a1830e0a-336f-4db8-bb68-c38834741464} <Fatal> : Logical error: 'Bad cast from type DB::ColumnVector<signed char> to DB::ColumnArray'.
2022.12.30 12:08:53.266867 [ 956784 ] {} <Trace> BaseDaemon: Received signal 6
2022.12.30 12:08:53.267648 [ 957342 ] {} <Fatal> BaseDaemon: ########################################
2022.12.30 12:08:53.268092 [ 957342 ] {} <Fatal> BaseDaemon: (version 22.13.1.1, build id: 1A971B7E7086651D8F7D657F38C47B058907AEEE) (from thread 956786) (query_id: a1830e0a-336f-4db8-bb68-c38834741464) (query: SELECT field1 FROM alias10__fuzz_13 WHERE arrayEnumerateDense(NULL, tuple('0.2147483646'), NULL) GROUP BY field1, arrayEnumerateDense(('0.02', '0.1', '0'), NULL) WITH TOTALS) Received signal Aborted (6)
2022.12.30 12:08:53.268493 [ 957342 ] {} <Fatal> BaseDaemon: 
2022.12.30 12:08:53.268776 [ 957342 ] {} <Fatal> BaseDaemon: Stack trace: 0x7fb9442cda7c 0x7fb944279476 0x7fb94425f7f3 0x217fa336 0x217fa3f5 0x217fa545 0x18be346a 0x18beb1cb 0x28c79cfa 0x2b78c5d6 0x2b78c313 0x2b748397 0x2b7452da 0x2b73d979 0x2b74de85 0x30d1fb99 0x30d203fc 0x30f863f4 0x30f82d7a 0x30f81b1e 0x7fb9442cbb43 0x7fb94435da00
2022.12.30 12:08:53.269014 [ 957342 ] {} <Fatal> BaseDaemon: 4. pthread_kill @ 0x7fb9442cda7c in ?
2022.12.30 12:08:53.269146 [ 957342 ] {} <Fatal> BaseDaemon: 5. gsignal @ 0x7fb944279476 in ?
2022.12.30 12:08:53.269356 [ 957342 ] {} <Fatal> BaseDaemon: 6. abort @ 0x7fb94425f7f3 in ?
2022.12.30 12:08:53.369859 [ 957342 ] {} <Fatal> BaseDaemon: 7. /home/milovidov/work/ClickHouse/src/Common/Exception.cpp:41: DB::abortOnFailedAssertion(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) @ 0x217fa336 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:53.467501 [ 957342 ] {} <Fatal> BaseDaemon: 8. /home/milovidov/work/ClickHouse/src/Common/Exception.cpp:64: DB::handle_error_code(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, bool, std::__1::vector<void*, std::__1::allocator<void*>> const&) @ 0x217fa3f5 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:53.552509 [ 957342 ] {} <Fatal> BaseDaemon: 9. /home/milovidov/work/ClickHouse/src/Common/Exception.cpp:78: DB::Exception::Exception(DB::Exception::MessageMasked const&, int, bool) @ 0x217fa545 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:53.648922 [ 957342 ] {} <Fatal> BaseDaemon: 10. /home/milovidov/work/ClickHouse/src/Common/Exception.h:41: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, bool) @ 0x18be346a in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:53.751217 [ 957342 ] {} <Fatal> BaseDaemon: 11. /home/milovidov/work/ClickHouse/src/Common/assert_cast.h:47: DB::ColumnArray const& assert_cast<DB::ColumnArray const&, DB::IColumn const&>(DB::IColumn const&) @ 0x18beb1cb in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:53.835141 [ 957342 ] {} <Fatal> BaseDaemon: 12. /home/milovidov/work/ClickHouse/src/DataTypes/Serializations/SerializationArray.cpp:254: DB::SerializationArray::serializeBinaryBulkStatePrefix(DB::IColumn const&, DB::ISerialization::SerializeBinaryBulkSettings&, std::__1::shared_ptr<DB::ISerialization::SerializeBinaryBulkState>&) const @ 0x28c79cfa in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:53.904051 [ 957342 ] {} <Fatal> BaseDaemon: 13. /home/milovidov/work/ClickHouse/src/Formats/NativeWriter.cpp:61: DB::writeData(DB::ISerialization const&, COW<DB::IColumn>::immutable_ptr<DB::IColumn> const&, DB::WriteBuffer&, unsigned long, unsigned long) @ 0x2b78c5d6 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:53.965541 [ 957342 ] {} <Fatal> BaseDaemon: 14. /home/milovidov/work/ClickHouse/src/Formats/NativeWriter.cpp:153: DB::NativeWriter::write(DB::Block const&) @ 0x2b78c313 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:54.009892 [ 957117 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 1.31 GiB, peak 1.53 GiB, free memory in arenas 28.67 MiB, will set to 1.43 GiB (RSS), difference: 124.47 MiB
2022.12.30 12:08:54.246021 [ 957342 ] {} <Fatal> BaseDaemon: 15. /home/milovidov/work/ClickHouse/src/Server/TCPHandler.cpp:931: DB::TCPHandler::sendTotals(DB::Block const&) @ 0x2b748397 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:54.406008 [ 956785 ] {} <Trace> KeeperTCPHandler: Received heartbeat for session #474
2022.12.30 12:08:54.519261 [ 957342 ] {} <Fatal> BaseDaemon: 16. /home/milovidov/work/ClickHouse/src/Server/TCPHandler.cpp:801: DB::TCPHandler::processOrdinaryQueryWithProcessors() @ 0x2b7452da in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:54.765581 [ 957342 ] {} <Fatal> BaseDaemon: 17. /home/milovidov/work/ClickHouse/src/Server/TCPHandler.cpp:389: DB::TCPHandler::runImpl() @ 0x2b73d979 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:55.009853 [ 957117 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 1.43 GiB, peak 1.53 GiB, free memory in arenas 28.31 MiB, will set to 1.47 GiB (RSS), difference: 41.22 MiB
2022.12.30 12:08:55.044380 [ 957342 ] {} <Fatal> BaseDaemon: 18. /home/milovidov/work/ClickHouse/src/Server/TCPHandler.cpp:1920: DB::TCPHandler::run() @ 0x2b74de85 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:55.064635 [ 957342 ] {} <Fatal> BaseDaemon: 19. /home/milovidov/work/ClickHouse/contrib/poco/Net/src/TCPServerConnection.cpp:43: Poco::Net::TCPServerConnection::start() @ 0x30d1fb99 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:55.090835 [ 957342 ] {} <Fatal> BaseDaemon: 20. /home/milovidov/work/ClickHouse/contrib/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x30d203fc in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:55.121364 [ 957342 ] {} <Fatal> BaseDaemon: 21. /home/milovidov/work/ClickHouse/contrib/poco/Foundation/src/ThreadPool.cpp:199: Poco::PooledThread::run() @ 0x30f863f4 in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:55.149539 [ 957342 ] {} <Fatal> BaseDaemon: 22. /home/milovidov/work/ClickHouse/contrib/poco/Foundation/src/Thread.cpp:56: Poco::(anonymous namespace)::RunnableHolder::run() @ 0x30f82d7a in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:55.176250 [ 957342 ] {} <Fatal> BaseDaemon: 23. /home/milovidov/work/ClickHouse/contrib/poco/Foundation/src/Thread_POSIX.cpp:345: Poco::ThreadImpl::runnableEntry(void*) @ 0x30f81b1e in /home/milovidov/work/ClickHouse/build_debug/programs/clickhouse
2022.12.30 12:08:55.176491 [ 957342 ] {} <Fatal> BaseDaemon: 24. ? @ 0x7fb9442cbb43 in ?
2022.12.30 12:08:55.176677 [ 957342 ] {} <Fatal> BaseDaemon: 25. ? @ 0x7fb94435da00 in ?
```
{
    if (!parallel_reading_coordinator)
        throw Exception("Coordinator for parallel reading from replicas is not initialized", ErrorCodes::LOGICAL_ERROR);
    auto response = parallel_reading_coordinator->handleRequest(std::move(request));
    connections->sendMergeTreeReadTaskResponse(response);
}
void RemoteQueryExecutor::finish(std::unique_ptr<ReadContext> * read_context)
{
    /** If one of:
      * - nothing started to do;
      * - received all packets before EndOfStream;
      * - received exception from one replica;
      * - received an unknown packet from one replica;
      * then you do not need to read anything.
      */
    if (!isQueryPending() || hasThrownException())
        return;
    /** If you have not read all the data yet, but they are no longer needed.
      * This may be due to the fact that the data is sufficient (for example, when using LIMIT).
      */
    
    tryCancel("Cancelling query because enough data has been read", read_context);
    if (context->getSettingsRef().drain_timeout != Poco::Timespan(-1000000))
    {
        auto connections_left = ConnectionCollector::enqueueConnectionCleanup(pool, connections);
        if (connections_left)