```
SELECT topKWeightedMergeState(1)(initializeAggregation('topKWeightedState(1)', nan, arrayJoin(range(10))))


clickhouse-server: /home/akuzm/ch4/ch/src/Common/HashTable/HashTable.h:817: void HashTable<double, HashMapCellWithSavedHash<double, DB::SpaceSaving<double, HashCRC32<DB::Float64> >::Counter *, HashCRC32<DB::Float64>, HashTableNoState>, HashCRC32<DB::Float64>, HashTableGrower<4>, AllocatorWithStackMemory<Allocator<true, true>, 384, 1> >::emplaceNonZeroImpl(size_t, KeyHolder &&, HashTable::LookupResult &, bool &, size_t) [Key = double, Cell = HashMapCellWithSavedHash<double, DB::SpaceSaving<double, HashCRC32<DB::Float64> >::Counter *, HashCRC32<DB::Float64>, HashTableNoState>, Hash = HashCRC32<DB::Float64>, Grower = HashTableGrower<4>, Allocator = AllocatorWithStackMemory<Allocator<true, true>, 384, 1>, KeyHolder = const double &]: Assertion `!buf[new_place].isZero(*this)' failed.
2020.07.14 17:00:30.322621 [ 155916 ] {} <Trace> BaseDaemon: Received signal 6
2020.07.14 17:00:30.323015 [ 155999 ] {} <Fatal> BaseDaemon: ########################################
2020.07.14 17:00:30.323536 [ 155999 ] {} <Fatal> BaseDaemon: (version 20.7.1.1, build id: F176DE2A5C050ABF) (from thread 155986) (query_id: 450762ad-4b6a-4838-855c-ce533020749a) Received signal Aborted (6)
2020.07.14 17:00:30.323670 [ 155999 ] {} <Fatal> BaseDaemon: 
2020.07.14 17:00:30.323857 [ 155999 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f14ac2ab18b 0x7f14ac28a859 0x7f14ac28a729 0x7f14ac29bf36 0x7f14aba6bd46 0x7f14aba6c37f 0x7f14aba7fc2a 0x7f14ab11793e 0x7f14ab117bc6 0x7f149f23eb01 0x7f149f23fd24 0x7f149b0cd450 0x7f149b0cb7b1 0x7f149ba114cc 0x7f149ba11440 0x7f149ba113fd 0x7f149ba113ad 0x7f149ba1137d 0x7f149ba104ce 0x7f14b09f1575 0x7f14b09f1515 0x7f149ba0eb05 0x7f149ba0f329 0x7f149ba0d850 0x7f149ba0cf36 0x7f149ba3ab5d 0x7f149ba3aac2 0x7f149ba3aa4d
2020.07.14 17:00:30.324231 [ 155999 ] {} <Fatal> BaseDaemon: 4. /build/glibc-YYA7BZ/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51: raise @ 0x4618b in /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so
2020.07.14 17:00:30.324410 [ 155999 ] {} <Fatal> BaseDaemon: 5. /build/glibc-YYA7BZ/glibc-2.31/stdlib/abort.c:81: abort @ 0x25859 in /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so
2020.07.14 17:00:30.324640 [ 155999 ] {} <Fatal> BaseDaemon: 6. /build/glibc-YYA7BZ/glibc-2.31/intl/loadmsgcat.c:509: _nl_load_domain.cold @ 0x25729 in /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so
2020.07.14 17:00:30.324913 [ 155999 ] {} <Fatal> BaseDaemon: 7. ? @ 0x36f36 in /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so
2020.07.14 17:00:30.333668 [ 155999 ] {} <Fatal> BaseDaemon: 8. /home/akuzm/ch4/ch/src/Common/HashTable/HashTable.h:813: DB::SpaceSaving<double, HashCRC32<double> >::rebuildCounterMap() @ 0x2fcad46 in /home/akuzm/ch4/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.07.14 17:00:30.342397 [ 155999 ] {} <Fatal> BaseDaemon: 9. /home/akuzm/ch4/ch/src/Common/SpaceSaving.h:259: DB::SpaceSaving<double, HashCRC32<double> >::merge(DB::SpaceSaving<double, HashCRC32<double> > const&) @ 0x2fcb37f in /home/akuzm/ch4/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.07.14 17:00:30.350287 [ 155999 ] {} <Fatal> BaseDaemon: 10. /home/akuzm/ch4/ch/src/AggregateFunctions/AggregateFunctionTopK.h:68: DB::AggregateFunctionTopK<double, true>::merge(char*, char const*, DB::Arena*) const @ 0x2fdec2a in /home/akuzm/ch4/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.07.14 17:00:30.351818 [ 155999 ] {} <Fatal> BaseDaemon: 11. /home/akuzm/ch4/ch/src/AggregateFunctions/AggregateFunctionMerge.h:79: DB::AggregateFunctionMerge::add(char*, DB::IColumn const**, unsigned long, DB::Arena*) const @ 0x267693e in /home/akuzm/ch4/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.07.14 17:00:30.353264 [ 155999 ] {} <Fatal> BaseDaemon: 12. /home/akuzm/ch4/ch/src/AggregateFunctions/IAggregateFunction.h:209: DB::IAggregateFunctionHelper<DB::AggregateFunctionMerge>::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const @ 0x2676bc6 in /home/akuzm/ch4/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.07.14 17:00:30.353877 [ 155999 ] {} <Fatal> BaseDaemon: 13. /home/akuzm/ch4/ch/src/Interpreters/Aggregator.cpp:576: DB::Aggregator::executeWithoutKeyImpl(char*&, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) @ 0xe41b01 in /home/akuzm/ch4/build-clang10/src/libclickhouse_interpretersd.so
2020.07.14 17:00:30.354446 [ 155999 ] {} <Fatal> BaseDaemon: 14. /home/akuzm/ch4/ch/src/Interpreters/Aggregator.cpp:719: DB::Aggregator::executeOnBlock(std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::__1::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn> > >, unsigned long, DB::AggregatedDataVariants&, std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> >&, std::__1::vector<std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> >, std::__1::allocator<std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> > > >&, bool&) @ 0xe42d24 in /home/akuzm/ch4/build-clang10/src/libclickhouse_interpretersd.so
2020.07.14 17:00:30.354953 [ 155999 ] {} <Fatal> BaseDaemon: 15. /home/akuzm/ch4/ch/src/Processors/Transforms/AggregatingTransform.cpp:524: DB::AggregatingTransform::consume(DB::Chunk) @ 0x222450 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_transformsd.so
2020.07.14 17:00:30.355393 [ 155999 ] {} <Fatal> BaseDaemon: 16. /home/akuzm/ch4/ch/src/Processors/Transforms/AggregatingTransform.cpp:494: DB::AggregatingTransform::work() @ 0x2207b1 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_transformsd.so
2020.07.14 17:00:30.356001 [ 155999 ] {} <Fatal> BaseDaemon: 17. /home/akuzm/ch4/ch/src/Processors/Executors/PipelineExecutor.cpp:155: DB::executeJob(DB::IProcessor*) @ 0x13d4cc in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.356684 [ 155999 ] {} <Fatal> BaseDaemon: 18. /home/akuzm/ch4/ch/src/Processors/Executors/PipelineExecutor.cpp:172: DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1::operator()() const @ 0x13d440 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.357438 [ 155999 ] {} <Fatal> BaseDaemon: 19. /home/akuzm/ch4/ch/contrib/libcxx/include/type_traits:3519: decltype(std::__1::forward<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1&>(fp)()) std::__1::__invoke<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1&>(DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1&) @ 0x13d3fd in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.358308 [ 155999 ] {} <Fatal> BaseDaemon: 20. /home/akuzm/ch4/ch/contrib/libcxx/include/__functional_base:349: void std::__1::__invoke_void_return_wrapper<void>::__call<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1&>(DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1&) @ 0x13d3ad in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.359217 [ 155999 ] {} <Fatal> BaseDaemon: 21. /home/akuzm/ch4/ch/contrib/libcxx/include/functional:1540: std::__1::__function::__alloc_func<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1, std::__1::allocator<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1>, void ()>::operator()() @ 0x13d37d in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.359850 [ 155999 ] {} <Fatal> BaseDaemon: 22. /home/akuzm/ch4/ch/contrib/libcxx/include/functional:1714: std::__1::__function::__func<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1, std::__1::allocator<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::$_1>, void ()>::operator()() @ 0x13c4ce in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.362338 [ 155999 ] {} <Fatal> BaseDaemon: 23. /home/akuzm/ch4/ch/contrib/libcxx/include/functional:1867: std::__1::__function::__value_func<void ()>::operator()() const @ 0x1c8575 in /home/akuzm/ch4/build-clang10/programs/server/libclickhouse-server-libd.so
2020.07.14 17:00:30.364166 [ 155999 ] {} <Fatal> BaseDaemon: 24. /home/akuzm/ch4/ch/contrib/libcxx/include/functional:2473: std::__1::function<void ()>::operator()() const @ 0x1c8515 in /home/akuzm/ch4/build-clang10/programs/server/libclickhouse-server-libd.so
2020.07.14 17:00:30.364681 [ 155999 ] {} <Fatal> BaseDaemon: 25. /home/akuzm/ch4/ch/src/Processors/Executors/PipelineExecutor.cpp:633: DB::PipelineExecutor::executeStepImpl(unsigned long, unsigned long, std::__1::atomic<bool>*) @ 0x13ab05 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.365095 [ 155999 ] {} <Fatal> BaseDaemon: 26. /home/akuzm/ch4/ch/src/Processors/Executors/PipelineExecutor.cpp:546: DB::PipelineExecutor::executeSingleThread(unsigned long, unsigned long) @ 0x13b329 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.365421 [ 155999 ] {} <Fatal> BaseDaemon: 27. /home/akuzm/ch4/ch/src/Processors/Executors/PipelineExecutor.cpp:812: DB::PipelineExecutor::executeImpl(unsigned long) @ 0x139850 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.365770 [ 155999 ] {} <Fatal> BaseDaemon: 28. /home/akuzm/ch4/ch/src/Processors/Executors/PipelineExecutor.cpp:479: DB::PipelineExecutor::execute(unsigned long) @ 0x138f36 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.366172 [ 155999 ] {} <Fatal> BaseDaemon: 29. /home/akuzm/ch4/ch/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:79: DB::threadFunction(DB::PullingAsyncPipelineExecutor::Data&, std::__1::shared_ptr<DB::ThreadGroupStatus>, unsigned long) @ 0x166b5d in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.366522 [ 155999 ] {} <Fatal> BaseDaemon: 30. /home/akuzm/ch4/ch/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:101: DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0::operator()() const @ 0x166ac2 in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
2020.07.14 17:00:30.366863 [ 155999 ] {} <Fatal> BaseDaemon: 31. /home/akuzm/ch4/ch/contrib/libcxx/include/type_traits:3525: decltype(std::__1::forward<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0 const&>(fp)()) std::__1::__invoke_constexpr<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0 const&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0 const&) @ 0x166a4d in /home/akuzm/ch4/build-clang10/src/libclickhouse_processors_executorsd.so
```
};
template <typename T>
struct AggregateFunctionUniqHLL12Data
{
    using Set = HyperLogLogWithSmallSetOptimization<T, 16, 12>;
    Set set;
    static String getName() { return "uniqHLL12"; }
};
template <>
struct AggregateFunctionUniqHLL12Data<String>
{
    using Set = HyperLogLogWithSmallSetOptimization<UInt64, 16, 12>;
    Set set;
    static String getName() { return "uniqHLL12"; }
};
template <>
struct AggregateFunctionUniqHLL12Data<UInt128>
{
    using Set = HyperLogLogWithSmallSetOptimization<UInt64, 16, 12>;
    Set set;
    static String getName() { return "uniqHLL12"; }
};
struct AggregateFunctionUniqHLL12DataForVariadic
{
    using Set = HyperLogLogWithSmallSetOptimization<UInt64, 16, 12, TrivialHash>;
    Set set;
    static String getName() { return "uniqHLL12"; }