Skip to content

WHERE condition on virtual column in engine=Merge: column '_table' already exists. #13993

@filimonov

Description

@filimonov
DROP TABLE IF EXISTS x_1;
DROP TABLE IF EXISTS x_2;
DROP TABLE IF EXISTS x;

create table x_1 engine=Log as select * from numbers(10);
create table x_2 engine=Log as select * from numbers(10);
create table x engine=Merge(default, 'x_.*') as x_1;

select _table, count() from x group by _table order by _table;

Problematic query

select * from x where _table = 'x_1';

Received exception from server (version 20.6.4):
Code: 15. DB::Exception: Received from localhost:9000. DB::Exception: Column '_table' already exists. Stack trace:

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x12400be0 in /usr/bin/clickhouse
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0xa2433fd in /usr/bin/clickhouse
2. ? @ 0xf1aedac in /usr/bin/clickhouse
3. DB::ExpressionActions::execute(DB::Block&, bool) const @ 0xf1a51ed in /usr/bin/clickhouse
4. 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&) @ 0xf241bea in /usr/bin/clickhouse
5. DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0xf1eff4d in /usr/bin/clickhouse
6. ? @ 0xf1f67ba in /usr/bin/clickhouse
7. 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&) @ 0xf1fe807 in /usr/bin/clickhouse
8. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, DB::Context const&, std::__1::shared_ptr<DB::IBlockInputStream> const&, DB::SelectQueryOptions const&) @ 0xf2002bf in /usr/bin/clickhouse
9. DB::StorageMerge::createSources(std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::SelectQueryInfo const&, DB::QueryProcessingStage::Enum const&, unsigned long, DB::Block const&, std::__1::tuple<std::__1::shared_ptr<DB::IStorage>, std::__1::shared_ptr<DB::RWLockImpl::LockHolderImpl>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > 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> > > >&, std::__1::shared_ptr<DB::Context> const&, unsigned long, bool, bool) @ 0xf6bf7c2 in /usr/bin/clickhouse
10. DB::StorageMerge::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) @ 0xf6c0804 in /usr/bin/clickhouse
11. 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) @ 0xfea47aa in /usr/bin/clickhouse
12. 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&) @ 0xf1f84a1 in /usr/bin/clickhouse
13. DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::shared_ptr<DB::IBlockInputStream> const&, std::__1::optional<DB::Pipe>) @ 0xf1fc3e2 in /usr/bin/clickhouse
14. DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0xf1fd9e4 in /usr/bin/clickhouse
15. DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0xf36a0ac in /usr/bin/clickhouse
16. DB::InterpreterSelectWithUnionQuery::execute() @ 0xf36a3c5 in /usr/bin/clickhouse
17. ? @ 0xf4e129f in /usr/bin/clickhouse
18. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0xf4e4a15 in /usr/bin/clickhouse
19. DB::TCPHandler::runImpl() @ 0xfb5e69c in /usr/bin/clickhouse
20. DB::TCPHandler::run() @ 0xfb5f420 in /usr/bin/clickhouse
21. Poco::Net::TCPServerConnection::start() @ 0x1231ea0b in /usr/bin/clickhouse
22. Poco::Net::TCPServerDispatcher::run() @ 0x1231ee9b in /usr/bin/clickhouse
23. Poco::PooledThread::run() @ 0x1249d9c6 in /usr/bin/clickhouse
24. Poco::ThreadImpl::runnableEntry(void*) @ 0x12498dc0 in /usr/bin/clickhouse
25. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
26. __clone @ 0x122103 in /usr/lib/x86_64-linux-gnu/libc-2.31.so

It's a regression (worked on 19.17 and older), but the importance is low.

Metadata

Metadata

Labels

bugConfirmed user-visible misbehaviour in official releaseminorPriority: minor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions