```
SELECT k, finalizeAggregation(quantilesTimingState(0.5)(x)) FROM (SELECT intDiv(number, if(number = 9223372036854775807, -2, if(number = 3, number = if(number = 1, NULL, 3), 1)) AS d) AS k, number % d AS x FROM system.numbers LIMIT 100000) GROUP BY k WITH TOTALS ORDER BY k ASC


2020.07.03 18:50:19.353673 [ 211079 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Debug> executeQuery: (from [::1]:49290) SELECT k, finalizeAggregation(quantilesTimingState(0.5)(x)) FROM (SELECT intDiv(number, if(number = 9223372036854775807, -2, if(number = 3, number = if(number = 1, NULL, 3), 1)) AS d) AS k, number % d AS x FROM system.numbers LIMIT 100000) GROUP BY k WITH TOTALS ORDER BY k ASC
2020.07.03 18:50:19.355850 [ 211079 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> ContextAccess (default): Access granted: SELECT(number) ON system.numbers
2020.07.03 18:50:19.357589 [ 211079 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> ContextAccess (default): Access granted: SELECT(number) ON system.numbers
2020.07.03 18:50:19.360456 [ 211079 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> InterpreterSelectQuery: FetchColumns -> Complete
2020.07.03 18:50:19.360646 [ 211079 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> InterpreterSelectQuery: FetchColumns -> Complete
2020.07.03 18:50:19.363671 [ 212444 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> AggregatingTransform: Aggregating
2020.07.03 18:50:19.363690 [ 212444 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> Aggregator: Aggregation method: nullable_keys128
2020.07.03 18:50:19.377766 [ 212444 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> AggregatingTransform: Aggregated. 100000 to 100000 rows (from 1.14 MiB) in 0.016777877 sec. (5960229.652416691 rows/sec., 68.21 MiB/sec.)
2020.07.03 18:50:19.377785 [ 212444 ] {bf6fd05b-01ae-4513-8b00-e6184184385d} <Trace> Aggregator: Merging aggregated data
2020.07.03 18:50:19.405868 [ 210897 ] {} <Trace> BaseDaemon: Received signal 11
2020.07.03 18:50:19.415011 [ 212918 ] {} <Fatal> BaseDaemon: ########################################
2020.07.03 18:50:19.415380 [ 212918 ] {} <Fatal> BaseDaemon: (version 20.6.1.1, build id: 9F9D31B92875D3FC) (from thread 212444) (query_id: bf6fd05b-01ae-4513-8b00-e6184184385d) Received signal Segmentation fault (11)
2020.07.03 18:50:19.415474 [ 212918 ] {} <Fatal> BaseDaemon: Address: NULL pointer. Access: read. Unknown si_code.
2020.07.03 18:50:19.415592 [ 212918 ] {} <Fatal> BaseDaemon: Stack trace: 0x9a7e0b0 0xe6debc0 0xe6e1f3d 0xbc4ddf2 0xa3cf851 0xe37d392 0xe37ffbd 0xef31649 0xed22e80 0xed55c21 0xed5a3a6 0xed5b92d 0xed5c361 0xed634fd 0x97d5dd7 0x97d4313 0x7f58ffd8e609 0x7f58ffca4103
2020.07.03 18:50:19.428937 [ 212918 ] {} <Fatal> BaseDaemon: 3. /home/akuzm/ch4/ch/src/AggregateFunctions/QuantileTiming.h:321: DB::QuantileTiming<short>::merge(DB::QuantileTiming<short> const&) @ 0x9a7e0b0 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.430962 [ 212918 ] {} <Fatal> BaseDaemon: 4. /home/akuzm/ch4/ch/src/Columns/ColumnAggregateFunction.cpp:195: DB::ColumnAggregateFunction::ensureOwnership() @ 0xe6debc0 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.432321 [ 212918 ] {} <Fatal> BaseDaemon: 5. /home/akuzm/ch4/ch/contrib/libcxx/include/memory:3826: DB::ColumnAggregateFunction::convertToValues(COW<DB::IColumn>::mutable_ptr<DB::IColumn>) @ 0xe6e1f3d in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.433772 [ 212918 ] {} <Fatal> BaseDaemon: 6. DB::FunctionFinalizeAggregation::executeImpl(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long) @ 0xbc4ddf2 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.434940 [ 212918 ] {} <Fatal> BaseDaemon: 7. DB::ExecutableFunctionAdaptor::execute(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) @ 0xa3cf851 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.435958 [ 212918 ] {} <Fatal> BaseDaemon: 8. /home/akuzm/ch4/ch/contrib/libcxx/include/vector:461: DB::ExpressionAction::execute(DB::Block&, bool) const @ 0xe37d392 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.437242 [ 212918 ] {} <Fatal> BaseDaemon: 9. /home/akuzm/ch4/ch/src/Interpreters/ExpressionActions.cpp:684: DB::ExpressionActions::execute(DB::Block&, bool) const @ 0xe37ffbd in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.438074 [ 212918 ] {} <Fatal> BaseDaemon: 10. /home/akuzm/ch4/ch/src/Processors/Transforms/ExpressionTransform.cpp:43: DB::ExpressionTransform::transform(DB::Chunk&) @ 0xef31649 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.438893 [ 212918 ] {} <Fatal> BaseDaemon: 11. /home/akuzm/ch4/ch/contrib/libcxx/include/type_traits:3695: DB::ISimpleTransform::work() @ 0xed22e80 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.439777 [ 212918 ] {} <Fatal> BaseDaemon: 12. /home/akuzm/ch4/ch/src/Processors/Executors/PipelineExecutor.cpp:167: std::__1::__function::__func<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::'lambda'(), std::__1::allocator<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::'lambda'()>, void ()>::operator()() @ 0xed55c21 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.441145 [ 212918 ] {} <Fatal> BaseDaemon: 13. /home/akuzm/ch4/ch/contrib/libcxx/include/exception:180: DB::PipelineExecutor::executeStepImpl(unsigned long, unsigned long, std::__1::atomic<bool>*) (.constprop.0) @ 0xed5a3a6 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.442586 [ 212918 ] {} <Fatal> BaseDaemon: 14. /home/akuzm/ch4/ch/contrib/libcxx/include/vector:461: DB::PipelineExecutor::executeImpl(unsigned long) @ 0xed5b92d in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.444151 [ 212918 ] {} <Fatal> BaseDaemon: 15. /home/akuzm/ch4/ch/contrib/libcxx/include/vector:1516: DB::PipelineExecutor::execute(unsigned long) @ 0xed5c361 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.445007 [ 212918 ] {} <Fatal> BaseDaemon: 16. /home/akuzm/ch4/ch/contrib/poco/Foundation/include/Poco/Event_POSIX.h:53: ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::'lambda'()>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::'lambda'()&&)::'lambda'()::operator()() const @ 0xed634fd in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.445372 [ 212918 ] {} <Fatal> BaseDaemon: 17. /home/akuzm/ch4/ch/contrib/libcxx/include/atomic:856: ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x97d5dd7 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.445536 [ 212918 ] {} <Fatal> BaseDaemon: 18. /home/akuzm/ch4/ch/contrib/libcxx/include/memory:2615: 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>)::'lambda1'()> >(void*) @ 0x97d4313 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2020.07.03 18:50:19.445614 [ 212918 ] {} <Fatal> BaseDaemon: 19. start_thread @ 0x9609 in /lib/x86_64-linux-gnu/libpthread-2.31.so
2020.07.03 18:50:19.445756 [ 212918 ] {} <Fatal> BaseDaemon: 20. /build/glibc-YYA7BZ/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97: __clone @ 0x122103 in /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so
```
{
    MutableColumnPtr res = func->getReturnTypeToPredict()->createColumn();
    res->reserve(data.size());
    auto * machine_learning_function = func.get();
    if (machine_learning_function)
    {
        if (data.size() == 1)
        {
            
            machine_learning_function->predictValues(data[0], *res, block, 0, block.rows(), arguments, context);
        }
        else
        {
            
            size_t row_num = 0;
            for (auto * val : data)
            {
                machine_learning_function->predictValues(val, *res, block, row_num, 1, arguments, context);
                ++row_num;
            }
        }
    }
    else
    {
        throw Exception("Illegal aggregate function is passed",
                ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
    }
    return res;
}
void ColumnAggregateFunction::ensureOwnership()