```
/4/ :) SELECT DISTINCT marks FROM system.parts WHERE (table = NULL) AND (database = currentDatabase()) AND (active = 1)


Received exception from server (version 20.6.1):
Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: Bad cast from type DB::ColumnNullable to DB::ColumnVector<char8_t>. Stack trace:

0. /home/akuzm/ch4/ch/contrib/poco/Foundation/src/Exception.cpp:27: Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x1152b5c0 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
1. /home/akuzm/ch4/ch/src/Common/Exception.cpp:37: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x97a736d in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
2. std::__1::enable_if<is_reference_v<DB::ColumnVector<char8_t> const&>, DB::ColumnVector<char8_t> const&>::type typeid_cast<DB::ColumnVector<char8_t> const&, DB::IColumn const>(DB::IColumn const&) @ 0xba0e327 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
3. /home/akuzm/ch4/ch/src/Storages/VirtualColumnUtils.cpp:132: DB::VirtualColumnUtils::filterBlockWithQuery(std::__1::shared_ptr<DB::IAST> const&, DB::Block&, DB::Context const&) @ 0xe9547ee in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
4. /home/akuzm/ch4/ch/src/Storages/System/StorageSystemPartsBase.cpp:159: DB::StoragesInfoStream::StoragesInfoStream(DB::SelectQueryInfo const&, DB::Context const&) @ 0xdc50237 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
5. /home/akuzm/ch4/ch/src/Storages/System/StorageSystemPartsBase.cpp:241: DB::StorageSystemPartsBase::read(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&, DB::SelectQueryInfo const&, DB::Context const&, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0xdc517f7 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
6. /home/akuzm/ch4/ch/src/Processors/QueryPlan/ReadFromStorageStep.cpp:42: DB::ReadFromStorageStep::ReadFromStorageStep(std::__1::shared_ptr<DB::RWLockImpl::LockHolderImpl>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const>&, DB::SelectQueryOptions, std::__1::shared_ptr<DB::IStorage>, 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&, DB::SelectQueryInfo const&, std::__1::shared_ptr<DB::Context>, DB::QueryProcessingStage::Enum, unsigned long, unsigned long) @ 0xf00c667 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
7. /home/akuzm/ch4/ch/contrib/libcxx/include/memory:3028: DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&, std::__1::shared_ptr<DB::PrewhereInfo> 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&) @ 0xe3d332d in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
8. /home/akuzm/ch4/ch/src/Interpreters/InterpreterSelectQuery.cpp:793: DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::shared_ptr<DB::IBlockInputStream> const&, std::__1::optional<DB::Pipe>) @ 0xe3d7252 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
9. /home/akuzm/ch4/ch/contrib/libcxx/include/optional:224: DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0xe3d8854 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
10. /home/akuzm/ch4/ch/contrib/libcxx/include/vector:1549: DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0xe53b57c in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
11. /home/akuzm/ch4/ch/src/Interpreters/InterpreterSelectWithUnionQuery.cpp:200: DB::InterpreterSelectWithUnionQuery::execute() @ 0xe53b8ac in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
12. /home/akuzm/ch4/ch/src/Interpreters/executeQuery.cpp:385: DB::executeQueryImpl(char const*, char const*, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, DB::ReadBuffer*) @ 0xe6ae372 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
13. /home/akuzm/ch4/ch/src/Interpreters/executeQuery.cpp:644: DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0xe6b1aaa in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
14. /home/akuzm/ch4/ch/src/Server/TCPHandler.cpp:253: DB::TCPHandler::runImpl() @ 0xece3bb6 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
15. /home/akuzm/ch4/ch/src/Server/TCPHandler.cpp:1203: DB::TCPHandler::run() @ 0xece4910 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
16. /home/akuzm/ch4/ch/contrib/poco/Net/src/TCPServerConnection.cpp:57: Poco::Net::TCPServerConnection::start() @ 0x1144942b in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
17. /home/akuzm/ch4/ch/contrib/libcxx/include/atomic:856: Poco::Net::TCPServerDispatcher::run() @ 0x114498bb in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
18. /home/akuzm/ch4/ch/contrib/poco/Foundation/include/Poco/Mutex_POSIX.h:59: Poco::PooledThread::run() @ 0x115c8396 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
19. /home/akuzm/ch4/ch/contrib/poco/Foundation/include/Poco/AutoPtr.h:223: Poco::ThreadImpl::runnableEntry(void*) @ 0x115c3790 in /home/akuzm/ch4/build-gcc9-rel/programs/clickhouse
20. start_thread @ 0x9609 in /lib/x86_64-linux-gnu/libpthread-2.31.so
21. /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
```
for (const auto & it : block.getNamesAndTypesList())
        columns.insert(it.name);
    
    std::vector<ASTPtr> functions;
    if (select.where())
        extractFunctions(select.where(), columns, functions);
    if (select.prewhere())
        extractFunctions(select.prewhere(), columns, functions);
    ASTPtr expression_ast = buildWhereExpression(functions);
    if (!expression_ast)
        return;
    
    auto syntax_result = SyntaxAnalyzer(context).analyze(expression_ast, block.getNamesAndTypesList());
    ExpressionAnalyzer analyzer(expression_ast, syntax_result, context);
    ExpressionActionsPtr actions = analyzer.getActions(false);
    Block block_with_filter = block;
    actions->execute(block_with_filter);
    
    String filter_column_name = expression_ast->getColumnName();
    ColumnPtr filter_column = block_with_filter.getByName(filter_column_name).column->convertToFullColumnIfConst();
    const IColumn::Filter & filter = typeid_cast<const ColumnUInt8 &>(*filter_column).getData();
    for (size_t i = 0; i < block.columns(); ++i)
    {
        ColumnPtr & column = block.safeGetByPosition(i).column;
        column = column->filter(filter, -1);
    }
}
}
}