```
CREATE TABLE click_conversion (click_city_id UInt32, click_country_id UInt32) Engine = Memory;
CREATE TABLE source_city (id UInt32, country_id UInt8, name String) Engine = Memory;

CREATE DICTIONARY city (id UInt32, country_id UInt8, name String) PRIMARY KEY id
SOURCE(CLICKHOUSE(host '127.0.0.1' port 9000 user 'default' password '' db 'default' table 'source_city'))
LIFETIME(MIN 300 MAX 360)
LAYOUT(HASHED());

select click_country_id
from click_conversion cc
left join city c on toUInt32(city.id) = cc.click_city_id
limit 10;
```

```
[chertus-nix] 2020.07.13 13:10:35.152421 [ 354617 ] <Fatal> BaseDaemon: ########################################
[chertus-nix] 2020.07.13 13:10:35.152884 [ 354617 ] <Fatal> BaseDaemon: (version 20.6.1.1, build id: A3B3932FA40C73D8AD79BD6C168A0C95E1BB2E7B) (from thread 300705) (query_id: 5c72cca4-d7b6-45e8-9cfb-96d757f0dcb9) Received signal Segmentation fault (11)
[chertus-nix] 2020.07.13 13:10:35.153060 [ 354617 ] <Fatal> BaseDaemon: Address: 0x28 Access: read. Address not mapped to object.
[chertus-nix] 2020.07.13 13:10:35.153242 [ 354617 ] <Fatal> BaseDaemon: Stack trace: 0xc60eca5 0xc61de53 0x13268c16 0x13ffcf1c 0x13ffc8d0 0x13ffc2be 0x140011e1 0x130e37eb 0x130e0fa4 0x130ddbed 0x130dcafc 0x131586a1 0x131573fd 0x130a6425 0x130a54ff 0x13286e98 0x1328617a 0x139044a3 0x1390b2d2 0x14f3558c 0x14f35d9c 0x1506a273 0x1506718d 0x15066018 0x7f5fdc60b609 0x7f5fdc521103
[chertus-nix] 2020.07.13 13:10:35.153588 [ 354617 ] <Fatal> BaseDaemon: 4. /home/chertus/src/ClickHouse/contrib/libcxx/include/string:1426: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__is_long() const @ 0xc60eca5 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.154016 [ 354617 ] <Fatal> BaseDaemon: 5. /home/chertus/src/ClickHouse/contrib/libcxx/include/string:1840: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0xc61de53 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.182608 [ 354617 ] <Fatal> BaseDaemon: 6. /home/chertus/src/ClickHouse/src/Interpreters/TableJoin.cpp:268: DB::TableJoin::allowDictJoin(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Block 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> > > >&, DB::NamesAndTypesList&) const @ 0x13268c16 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.213356 [ 354617 ] <Fatal> BaseDaemon: 7. /home/chertus/src/ClickHouse/src/Interpreters/ExpressionAnalyzer.cpp:561: DB::makeJoin(std::__1::shared_ptr<DB::TableJoin>, DB::Block const&, DB::Context const&) @ 0x13ffcf1c in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.243721 [ 354617 ] <Fatal> BaseDaemon: 8. /home/chertus/src/ClickHouse/src/Interpreters/ExpressionAnalyzer.cpp:612: DB::SelectQueryExpressionAnalyzer::makeTableJoin(DB::ASTTablesInSelectQueryElement const&) @ 0x13ffc8d0 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.274114 [ 354617 ] <Fatal> BaseDaemon: 9. /home/chertus/src/ClickHouse/src/Interpreters/ExpressionAnalyzer.cpp:509: DB::SelectQueryExpressionAnalyzer::appendJoin(DB::ExpressionActionsChain&) @ 0x13ffc2be in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.305149 [ 354617 ] <Fatal> BaseDaemon: 10. /home/chertus/src/ClickHouse/src/Interpreters/ExpressionAnalyzer.cpp:1106: DB::ExpressionAnalysisResult::ExpressionAnalysisResult(DB::SelectQueryExpressionAnalyzer&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, bool, bool, bool, std::__1::shared_ptr<DB::FilterInfo> const&, DB::Block const&) @ 0x140011e1 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.329835 [ 354617 ] <Fatal> BaseDaemon: 11. /home/chertus/src/ClickHouse/src/Interpreters/InterpreterSelectQuery.cpp:505: DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0x130e37eb in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.354062 [ 354617 ] <Fatal> BaseDaemon: 12. /home/chertus/src/ClickHouse/src/Interpreters/InterpreterSelectQuery.cpp:402: DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, DB::Context const&, std::__1::shared_ptr<DB::IBlockInputStream> const&, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions 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> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&)::$_2::operator()(bool) const @ 0x130e0fa4 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.378221 [ 354617 ] <Fatal> BaseDaemon: 13. /home/chertus/src/ClickHouse/src/Interpreters/InterpreterSelectQuery.cpp:405: DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, DB::Context const&, std::__1::shared_ptr<DB::IBlockInputStream> const&, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions 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> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&) @ 0x130ddbed in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.401945 [ 354617 ] <Fatal> BaseDaemon: 14. /home/chertus/src/ClickHouse/src/Interpreters/InterpreterSelectQuery.cpp:146: DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, DB::Context const&, DB::SelectQueryOptions 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> > > > const&) @ 0x130dcafc in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.425252 [ 354617 ] <Fatal> BaseDaemon: 15. /home/chertus/src/ClickHouse/contrib/libcxx/include/memory:3028: std::__1::__unique_if<DB::InterpreterSelectQuery>::__unique_single std::__1::make_unique<DB::InterpreterSelectQuery, std::__1::shared_ptr<DB::IAST>&, DB::Context&, DB::SelectQueryOptions&, 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> > > > const&>(std::__1::shared_ptr<DB::IAST>&, DB::Context&, DB::SelectQueryOptions&, 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> > > > const&) @ 0x131586a1 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.448965 [ 354617 ] <Fatal> BaseDaemon: 16. /home/chertus/src/ClickHouse/src/Interpreters/InterpreterSelectWithUnionQuery.cpp:84: DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, DB::Context const&, DB::SelectQueryOptions 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> > > > const&) @ 0x131573fd in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.472124 [ 354617 ] <Fatal> BaseDaemon: 17. /home/chertus/src/ClickHouse/contrib/libcxx/include/memory:3028: std::__1::__unique_if<DB::InterpreterSelectWithUnionQuery>::__unique_single std::__1::make_unique<DB::InterpreterSelectWithUnionQuery, std::__1::shared_ptr<DB::IAST>&, DB::Context&, DB::SelectQueryOptions>(std::__1::shared_ptr<DB::IAST>&, DB::Context&, DB::SelectQueryOptions&&) @ 0x130a6425 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.495458 [ 354617 ] <Fatal> BaseDaemon: 18. /home/chertus/src/ClickHouse/src/Interpreters/InterpreterFactory.cpp:103: DB::InterpreterFactory::get(std::__1::shared_ptr<DB::IAST>&, DB::Context&, DB::QueryProcessingStage::Enum) @ 0x130a54ff in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.520229 [ 354617 ] <Fatal> BaseDaemon: 19. /home/chertus/src/ClickHouse/src/Interpreters/executeQuery.cpp:365: DB::executeQueryImpl(char const*, char const*, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, DB::ReadBuffer*) @ 0x13286e98 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.544750 [ 354617 ] <Fatal> BaseDaemon: 20. /home/chertus/src/ClickHouse/src/Interpreters/executeQuery.cpp:653: DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0x1328617a in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.572368 [ 354617 ] <Fatal> BaseDaemon: 21. /home/chertus/src/ClickHouse/src/Server/TCPHandler.cpp:253: DB::TCPHandler::runImpl() @ 0x139044a3 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.600256 [ 354617 ] <Fatal> BaseDaemon: 22. /home/chertus/src/ClickHouse/src/Server/TCPHandler.cpp:1201: DB::TCPHandler::run() @ 0x1390b2d2 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.634822 [ 354617 ] <Fatal> BaseDaemon: 23. /home/chertus/src/ClickHouse/contrib/poco/Net/src/TCPServerConnection.cpp:43: Poco::Net::TCPServerConnection::start() @ 0x14f3558c in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.669439 [ 354617 ] <Fatal> BaseDaemon: 24. /home/chertus/src/ClickHouse/contrib/poco/Net/src/TCPServerDispatcher.cpp:114: Poco::Net::TCPServerDispatcher::run() @ 0x14f35d9c in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.704567 [ 354617 ] <Fatal> BaseDaemon: 25. /home/chertus/src/ClickHouse/contrib/poco/Foundation/src/ThreadPool.cpp:199: Poco::PooledThread::run() @ 0x1506a273 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.739586 [ 354617 ] <Fatal> BaseDaemon: 26. /home/chertus/src/ClickHouse/contrib/poco/Foundation/src/Thread.cpp:56: Poco::(anonymous namespace)::RunnableHolder::run() @ 0x1506718d in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.775629 [ 354617 ] <Fatal> BaseDaemon: 27. /home/chertus/src/ClickHouse/contrib/poco/Foundation/src/Thread_POSIX.cpp:345: Poco::ThreadImpl::runnableEntry(void*) @ 0x15066018 in /home/chertus/src/ClickHouse/_build/programs/clickhouse
[chertus-nix] 2020.07.13 13:10:35.775852 [ 354617 ] <Fatal> BaseDaemon: 28. start_thread @ 0x9609 in /lib/x86_64-linux-gnu/libpthread-2.31.so
[chertus-nix] 2020.07.13 13:10:35.776178 [ 354617 ] <Fatal> BaseDaemon: 29. /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
```
{
    if (rightBecomeNullable(joined_column.type))
        columns_added_by_join.emplace_back(NameAndTypePair(joined_column.name, makeNullable(joined_column.type)));
    else
        columns_added_by_join.push_back(joined_column);
}
void TableJoin::addJoinedColumnsAndCorrectNullability(Block & sample_block) const
{
    for (auto & col : sample_block)
    {
        
        
        
        if (col.column)
            col.column = nullptr;
        if (leftBecomeNullable(col.type))
            col.type = makeNullable(col.type);
    }
    for (const auto & col : columns_added_by_join)
    {
        auto res_type = col.type;
        if (rightBecomeNullable(res_type))
            res_type = makeNullable(res_type);
        sample_block.insert(ColumnWithTypeAndName(nullptr, res_type, col.name));
    }
}
bool TableJoin::sameJoin(const TableJoin * x, const TableJoin * y)