```
select initializeAggregation('sumMapState', [1, 2], [1, 2], [1, null])



2020.09.21 20:35:42.144442 [ 1312410 ] {6dcf02ac-c157-4548-8f69-67f146de3f1c} <Error> : Logical error: 'Cannot sum Nulls'.
clickhouse-server: /home/akuzm/ch2/ch/src/Common/Exception.cpp:45: DB::Exception::Exception(const std::string &, int): Assertion `false' failed.
2020.09.21 20:35:42.144773 [ 1312346 ] {} <Trace> BaseDaemon: Received signal 6
2020.09.21 20:35:42.145108 [ 1312420 ] {} <Fatal> BaseDaemon: ########################################
2020.09.21 20:35:42.145650 [ 1312420 ] {} <Fatal> BaseDaemon: (version 20.10.1.1, build id: 2B558334E2794B91) (from thread 1312410) (query_id: 6dcf02ac-c157-4548-8f69-67f146de3f1c) Received signal Aborted (6)
2020.09.21 20:35:42.145773 [ 1312420 ] {} <Fatal> BaseDaemon: 
2020.09.21 20:35:42.145972 [ 1312420 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f2bdc36b18b 0x7f2bdc34a859 0x7f2bdc34a729 0x7f2bdc35bf36 0x7f2be02af505 0x7f2bdb4606f4 0x7f2bdb4603c1 0x7f2bdb45fb12 0x7f2bdb4b2653 0x7f2bdb4b3571 0x7f2bd4aef0cb 0x7f2bd2964581 0x7f2bd2963a8f 0x7f2bd3522c83 0x7f2bd352285e 0x7f2bd3522c00 0x7f2bd3523d8d 0x7f2bcb0667f6 0x7f2bcb06a034 0x7f2bcb069a33 0x7f2bcac400c2 0x7f2bcac49fa6 0x7f2bcac4370a 0x7f2bcac40697 0x7f2bcb08a58d 0x7f2bcb098876 0x7f2bcb08a59f 0x7f2bcb08113d
2020.09.21 20:35:42.146326 [ 1312420 ] {} <Fatal> BaseDaemon: 4. /build/glibc-YYA7BZ/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51: __GI_raise @ 0x4618b in /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so
2020.09.21 20:35:42.146483 [ 1312420 ] {} <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.09.21 20:35:42.146692 [ 1312420 ] {} <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.09.21 20:35:42.146956 [ 1312420 ] {} <Fatal> BaseDaemon: 7. ? @ 0x36f36 in /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so
2020.09.21 20:35:42.147243 [ 1312420 ] {} <Fatal> BaseDaemon: 8. /home/akuzm/ch2/ch/src/Common/Exception.cpp:48: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x2b4505 in /home/akuzm/ch2/build-clang10/src/libclickhouse_common_iod.so
2020.09.21 20:35:42.151546 [ 1312420 ] {} <Fatal> BaseDaemon: 9. /home/akuzm/ch2/ch/src/Common/FieldVisitors.h:253: DB::FieldVisitorSum::operator()(DB::Null&) const @ 0x4f276f4 in /home/akuzm/ch2/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.09.21 20:35:42.155755 [ 1312420 ] {} <Fatal> BaseDaemon: 10. /home/akuzm/ch2/ch/src/Core/Field.h:563: auto DB::Field::dispatch<DB::FieldVisitorSum, DB::Field&>(DB::FieldVisitorSum&&, DB::Field&) @ 0x4f273c1 in /home/akuzm/ch2/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.09.21 20:35:42.159981 [ 1312420 ] {} <Fatal> BaseDaemon: 11. /home/akuzm/ch2/ch/src/Common/FieldVisitors.h:45: auto DB::applyVisitor<DB::FieldVisitorSum, DB::Field&>(DB::FieldVisitorSum&&, DB::Field&) @ 0x4f26b12 in /home/akuzm/ch2/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.09.21 20:35:42.167089 [ 1312420 ] {} <Fatal> BaseDaemon: 12. /home/akuzm/ch2/ch/src/AggregateFunctions/AggregateFunctionSumMap.h:173: DB::AggregateFunctionMapBase<char8_t, DB::AggregateFunctionSumMap<char8_t, false, false>, DB::FieldVisitorSum, false, false>::add(char*, DB::IColumn const**, unsigned long, DB::Arena*) const @ 0x4f79653 in /home/akuzm/ch2/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.09.21 20:35:42.174250 [ 1312420 ] {} <Fatal> BaseDaemon: 13. /home/akuzm/ch2/ch/src/AggregateFunctions/IAggregateFunction.h:223: DB::IAggregateFunctionHelper<DB::AggregateFunctionSumMap<char8_t, false, false> >::addBatch(unsigned long, char**, unsigned long, DB::IColumn const**, DB::Arena*) const @ 0x4f7a571 in /home/akuzm/ch2/build-clang10/src/AggregateFunctions/libclickhouse_aggregate_functionsd.so
2020.09.21 20:35:42.180593 [ 1312420 ] {} <Fatal> BaseDaemon: 14. /home/akuzm/ch2/ch/src/Functions/initializeAggregation.cpp:145: DB::(anonymous namespace)::FunctionInitializeAggregation::executeImpl(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long) const @ 0x4cd00cb in /home/akuzm/ch2/build-clang10/src/Functions/libclickhouse_functionsd.so
2020.09.21 20:35:42.181058 [ 1312420 ] {} <Fatal> BaseDaemon: 15. /home/akuzm/ch2/ch/src/Functions/IFunctionImpl.h:202: DB::IFunction::executeImplDryRun(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long) const @ 0x2b45581 in /home/akuzm/ch2/build-clang10/src/Functions/libclickhouse_functionsd.so
2020.09.21 20:35:42.181477 [ 1312420 ] {} <Fatal> BaseDaemon: 16. /home/akuzm/ch2/ch/src/Functions/IFunctionAdaptors.h:156: DB::DefaultExecutable::executeDryRun(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long) @ 0x2b44a8f in /home/akuzm/ch2/build-clang10/src/Functions/libclickhouse_functionsd.so
2020.09.21 20:35:42.183019 [ 1312420 ] {} <Fatal> BaseDaemon: 17. /home/akuzm/ch2/ch/src/Functions/IFunction.cpp:323: DB::ExecutableFunctionAdaptor::executeWithoutLowCardinalityColumns(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) @ 0x3703c83 in /home/akuzm/ch2/build-clang10/src/Functions/libclickhouse_functionsd.so
2020.09.21 20:35:42.184584 [ 1312420 ] {} <Fatal> BaseDaemon: 18. /home/akuzm/ch2/ch/src/Functions/IFunction.cpp:266: DB::ExecutableFunctionAdaptor::defaultImplementationForConstantArguments(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) @ 0x370385e in /home/akuzm/ch2/build-clang10/src/Functions/libclickhouse_functionsd.so
2020.09.21 20:35:42.186387 [ 1312420 ] {} <Fatal> BaseDaemon: 19. /home/akuzm/ch2/ch/src/Functions/IFunction.cpp:316: DB::ExecutableFunctionAdaptor::executeWithoutLowCardinalityColumns(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) @ 0x3703c00 in /home/akuzm/ch2/build-clang10/src/Functions/libclickhouse_functionsd.so
2020.09.21 20:35:42.188607 [ 1312420 ] {} <Fatal> BaseDaemon: 20. /home/akuzm/ch2/ch/src/Functions/IFunction.cpp:486: DB::ExecutableFunctionAdaptor::execute(DB::Block&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) @ 0x3704d8d in /home/akuzm/ch2/build-clang10/src/Functions/libclickhouse_functionsd.so
2020.09.21 20:35:42.190592 [ 1312420 ] {} <Fatal> BaseDaemon: 21. /home/akuzm/ch2/ch/src/Interpreters/ExpressionActions.cpp:201: DB::ExpressionAction::prepare(DB::Block&, DB::Settings const&, std::__1::unordered_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) @ 0x13aa7f6 in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.192425 [ 1312420 ] {} <Fatal> BaseDaemon: 22. /home/akuzm/ch2/ch/src/Interpreters/ExpressionActions.cpp:597: DB::ExpressionActions::addImpl(DB::ExpressionAction, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) @ 0x13ae034 in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.193804 [ 1312420 ] {} <Fatal> BaseDaemon: 23. /home/akuzm/ch2/ch/src/Interpreters/ExpressionActions.cpp:561: DB::ExpressionActions::add(DB::ExpressionAction const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) @ 0x13ada33 in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.194196 [ 1312420 ] {} <Fatal> BaseDaemon: 24. /home/akuzm/ch2/ch/src/Interpreters/ActionsVisitor.cpp:438: DB::ScopeStack::addAction(DB::ExpressionAction const&) @ 0xf840c2 in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.194669 [ 1312420 ] {} <Fatal> BaseDaemon: 25. /home/akuzm/ch2/ch/src/Interpreters/ActionsVisitor.h:120: DB::ActionsMatcher::Data::addAction(DB::ExpressionAction const&) @ 0xf8dfa6 in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.194958 [ 1312420 ] {} <Fatal> BaseDaemon: 26. /home/akuzm/ch2/ch/src/Interpreters/ActionsVisitor.cpp:790: DB::ActionsMatcher::visit(DB::ASTFunction const&, std::__1::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0xf8770a in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.195206 [ 1312420 ] {} <Fatal> BaseDaemon: 27. /home/akuzm/ch2/ch/src/Interpreters/ActionsVisitor.cpp:508: DB::ActionsMatcher::visit(std::__1::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0xf84697 in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.196457 [ 1312420 ] {} <Fatal> BaseDaemon: 28. /home/akuzm/ch2/ch/src/Interpreters/InDepthNodeVisitor.h:32: DB::InDepthNodeVisitor<DB::ActionsMatcher, true, std::__1::shared_ptr<DB::IAST> const>::visit(std::__1::shared_ptr<DB::IAST> const&) @ 0x13ce58d in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.200321 [ 1312420 ] {} <Fatal> BaseDaemon: 29. /home/akuzm/ch2/ch/src/Interpreters/InDepthNodeVisitor.h:45: DB::InDepthNodeVisitor<DB::ActionsMatcher, true, std::__1::shared_ptr<DB::IAST> const>::visitChildren(std::__1::shared_ptr<DB::IAST> const&) @ 0x13dc876 in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.201857 [ 1312420 ] {} <Fatal> BaseDaemon: 30. /home/akuzm/ch2/ch/src/Interpreters/InDepthNodeVisitor.h:35: DB::InDepthNodeVisitor<DB::ActionsMatcher, true, std::__1::shared_ptr<DB::IAST> const>::visit(std::__1::shared_ptr<DB::IAST> const&) @ 0x13ce59f in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
2020.09.21 20:35:42.203536 [ 1312420 ] {} <Fatal> BaseDaemon: 31. /home/akuzm/ch2/ch/src/Interpreters/ExpressionAnalyzer.cpp:384: DB::ExpressionAnalyzer::getRootActions(std::__1::shared_ptr<DB::IAST> const&, bool, std::__1::shared_ptr<DB::ExpressionActions>&, bool) @ 0x13c513d in /home/akuzm/ch2/build-clang10/src/libclickhouse_interpretersd.so
```
{
        auto val = get<DecimalField<T>>(rhs);
        if (val > x)
        {
            x = val;
            return true;
        }
        return false;
    }
    template <typename T>
    bool operator() (T & x) const
    {
        auto val = get<T>(rhs);
        if (val > x)
        {
            x = val;
            return true;
        }
        return false;
    }
};
/** Implements `Min` operation.
 *  Returns true if changed
 */
class FieldVisitorMin : public StaticVisitor<bool>
{
private:
    const Field & rhs;
public:
    explicit FieldVisitorMin(const Field & rhs_) : rhs(rhs_) {}