Skip to content

Cross join failed with the error 'Missing columns: "x" while processing query' #9861

@vladimir-golovchenko

Description

@vladimir-golovchenko

Cross join failed with the error 'Missing columns: "x" while processing query' when column referenced from a subquery in where-clause.

This query works:

SELECT dummy, name
FROM system.one, system.columns
WHERE (SELECT count() FROM system.columns WHERE name != '') > 0 AND dummy = 0
LIMIT 1;

These ones failed:

SELECT dummy, name
FROM system.one, system.columns
WHERE (SELECT count() FROM system.columns WHERE name != '' AND dummy = 0) > 0
LIMIT 1;

# fail
SELECT o.dummy, name
FROM system.one o, system.columns
WHERE (SELECT count() FROM system.columns WHERE name != '' AND o.dummy = 0) > 0
LIMIT 1;

with error:

Received exception from server (version 20.3.4):
Code: 47. DB::Exception: Received from localhost:9000. DB::Exception: Missing columns: 'dummy' while processing query: 'SELECT count() FROM system.columns WHERE (name != '') AND (dummy = 0)', required columns: 'name' 'dummy', source columns: 'is_in_sorting_key' 'marks_bytes' 'database' 'data_uncompressed_bytes' 'comment' 'is_in_primary_key' 'data_compressed_bytes' 'default_expression' 'table' 'default_kind' 'type' 'is_in_partition_key' 'compression_codec' 'is_in_sampling_key' 'name'. Stack trace:

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x102e0d8c in /usr/bin/clickhouse
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x8f2d989 in /usr/bin/clickhouse
2. ? @ 0xd34d3ac in /usr/bin/clickhouse
3. DB::SyntaxAnalyzer::analyzeSelect(std::__1::shared_ptr<DB::IAST>&, DB::SyntaxAnalyzerResult&&, DB::SelectQueryOptions const&, std::__1::vector<DB::TableWithColumnNamesAndTypes, std::__1::allocator<DB::TableWithColumnNamesAndTypes> > 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&) const @ 0xd34980f in /usr/bin/clickhouse
4. ? @ 0xcfb9135 in /usr/bin/clickhouse
5. 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&) @ 0xcfba3f0 in /usr/bin/clickhouse
6. 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&) @ 0xcfbb965 in /usr/bin/clickhouse
7. 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&) @ 0xd1b75a6 in /usr/bin/clickhouse
8. DB::ExecuteScalarSubqueriesMatcher::visit(DB::ASTSubquery const&, std::__1::shared_ptr<DB::IAST>&, DB::ExecuteScalarSubqueriesMatcher::Data&) @ 0xd35ea6a in /usr/bin/clickhouse
9. DB::ExecuteScalarSubqueriesMatcher::visit(std::__1::shared_ptr<DB::IAST>&, DB::ExecuteScalarSubqueriesMatcher::Data&) @ 0xd361392 in /usr/bin/clickhouse
10. DB::InDepthNodeVisitor<DB::ExecuteScalarSubqueriesMatcher, true, std::__1::shared_ptr<DB::IAST> >::visit(std::__1::shared_ptr<DB::IAST>&) @ 0xd352ca5 in /usr/bin/clickhouse
11. DB::InDepthNodeVisitor<DB::ExecuteScalarSubqueriesMatcher, true, std::__1::shared_ptr<DB::IAST> >::visit(std::__1::shared_ptr<DB::IAST>&) @ 0xd352ce3 in /usr/bin/clickhouse
12. DB::ExecuteScalarSubqueriesMatcher::visit(DB::ASTFunction const&, std::__1::shared_ptr<DB::IAST>&, DB::ExecuteScalarSubqueriesMatcher::Data&) @ 0xd360e1a in /usr/bin/clickhouse
13. DB::ExecuteScalarSubqueriesMatcher::visit(std::__1::shared_ptr<DB::IAST>&, DB::ExecuteScalarSubqueriesMatcher::Data&) @ 0xd3613bc in /usr/bin/clickhouse
14. DB::InDepthNodeVisitor<DB::ExecuteScalarSubqueriesMatcher, true, std::__1::shared_ptr<DB::IAST> >::visit(std::__1::shared_ptr<DB::IAST>&) @ 0xd352ca5 in /usr/bin/clickhouse
15. DB::SyntaxAnalyzer::analyzeSelect(std::__1::shared_ptr<DB::IAST>&, DB::SyntaxAnalyzerResult&&, DB::SelectQueryOptions const&, std::__1::vector<DB::TableWithColumnNamesAndTypes, std::__1::allocator<DB::TableWithColumnNamesAndTypes> > 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&) const @ 0xd348a7a in /usr/bin/clickhouse
16. ? @ 0xcfb9135 in /usr/bin/clickhouse
17. 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&) @ 0xcfba3f0 in /usr/bin/clickhouse
18. 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&) @ 0xcfbb965 in /usr/bin/clickhouse
19. 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&) @ 0xd1b75a6 in /usr/bin/clickhouse
20. DB::InterpreterFactory::get(std::__1::shared_ptr<DB::IAST>&, DB::Context&, DB::QueryProcessingStage::Enum) @ 0xcf0fbf4 in /usr/bin/clickhouse
21. ? @ 0xd3b42d5 in /usr/bin/clickhouse
22. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, bool) @ 0xd3b6fcd in /usr/bin/clickhouse
23. DB::TCPHandler::runImpl() @ 0x900a729 in /usr/bin/clickhouse
24. DB::TCPHandler::run() @ 0x900b63c in /usr/bin/clickhouse
25. Poco::Net::TCPServerConnection::start() @ 0xe095ab7 in /usr/bin/clickhouse
26. Poco::Net::TCPServerDispatcher::run() @ 0xe095f1d in /usr/bin/clickhouse
27. Poco::PooledThread::run() @ 0x1036af7f in /usr/bin/clickhouse
28. Poco::ThreadImpl::runnableEntry(void*) @ 0x10366fc8 in /usr/bin/clickhouse
29. ? @ 0x10368869 in /usr/bin/clickhouse
30. start_thread @ 0x76db in /lib/x86_64-linux-gnu/libpthread-2.27.so
31. __clone @ 0x12188f in /lib/x86_64-linux-gnu/libc-2.27.so

[CH 20.3.4.10]

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official releaseduplicatefeature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions