Skip to content

Logical error: 'Bad cast from type DB::IdentifierNode to DB::ColumnNode' #80620

@PedroTadim

Description

@PedroTadim

Describe the bug

Easy to reproduce.

How to reproduce

On a debug build run:

CREATE FUNCTION f0 AS (x) -> x;
SELECT 1 FROM (SELECT 1) tx JOIN VALUES(f0(*)) ty USING (c0);

Error message and/or stacktrace

Stack trace:

<Fatal> : Logical error: 'Bad cast from type DB::IdentifierNode to DB::ColumnNode'.
<Fatal> : Stack trace (when copying this message, always include the lines below):

0. contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x000000001d6ae8b2
1. src/Common/Exception.cpp:110: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x00000000121d4766
2. src/Common/Exception.h:119: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000bac9b4c
3. src/Common/Exception.h:137: DB::Exception::Exception<String, String>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<String>::type>, String&&, String&&) @ 0x000000000bac8b96
4. src/Common/typeid_cast.h:31: T typeid_cast<DB::ColumnNode&, DB::IQueryTreeNode>(DB::IQueryTreeNode&) @ 0x0000000016822793
5. src/Common/TypePromotion.h:31: DB::QueryAnalyzer::updateMatchedColumnsFromJoinUsing(std::vector<std::pair<std::shared_ptr<DB::IQueryTreeNode>, String>, std::allocator<std::pair<std::shared_ptr<DB::IQueryTreeNode>, String>>>&, std::shared_ptr<DB::IQueryTreeNode> const&, DB::IdentifierResolveScope&) @ 0x0000000016873926
6. src/Analyzer/Resolve/QueryAnalyzer.cpp:2213: DB::QueryAnalyzer::resolveUnqualifiedMatcher(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&) @ 0x0000000016881bca
7. src/Analyzer/Resolve/QueryAnalyzer.cpp:2243: DB::QueryAnalyzer::resolveMatcher(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&) @ 0x0000000016882ef4
8. src/Analyzer/Resolve/QueryAnalyzer.cpp:3872: DB::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, bool, bool, bool) @ 0x0000000016860ba8
9. src/Analyzer/Resolve/QueryAnalyzer.cpp:4063: DB::QueryAnalyzer::resolveExpressionNodeList(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, bool, bool) @ 0x000000001685fcb1
10. src/Analyzer/Resolve/QueryAnalyzer.cpp:2942: DB::QueryAnalyzer::resolveFunction(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&) @ 0x0000000016876d57
11. src/Analyzer/Resolve/QueryAnalyzer.cpp:3912: DB::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, bool, bool, bool) @ 0x000000001686091e
12. src/Analyzer/Resolve/QueryAnalyzer.cpp:4885: DB::QueryAnalyzer::resolveTableFunction(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, DB::QueryExpressionsAliasVisitor&, bool) @ 0x000000001686383d
13. src/Analyzer/Resolve/QueryAnalyzer.cpp:5480: DB::QueryAnalyzer::resolveQueryJoinTreeNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, DB::QueryExpressionsAliasVisitor&) @ 0x000000001688cecf
14. src/Analyzer/Resolve/QueryAnalyzer.cpp:5274: DB::QueryAnalyzer::resolveJoin(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, DB::QueryExpressionsAliasVisitor&) @ 0x000000001688e581
15. src/Analyzer/Resolve/QueryAnalyzer.cpp:5499: DB::QueryAnalyzer::resolveQueryJoinTreeNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, DB::QueryExpressionsAliasVisitor&) @ 0x000000001688cee2
16. src/Analyzer/Resolve/QueryAnalyzer.cpp:5738: DB::QueryAnalyzer::resolveQuery(std::shared_ptr<DB::IQueryTreeNode> const&, DB::IdentifierResolveScope&) @ 0x0000000016859f04
17. src/Analyzer/Resolve/QueryAnalyzer.cpp:179: DB::QueryAnalyzer::resolve(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::IQueryTreeNode> const&, std::shared_ptr<DB::Context const>) @ 0x0000000016859019
18. src/Analyzer/Resolve/QueryAnalysisPass.cpp:18: DB::QueryAnalysisPass::run(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::Context const>) @ 0x0000000016858810
19. src/Analyzer/QueryTreePassManager.cpp:187: DB::QueryTreePassManager::run(std::shared_ptr<DB::IQueryTreeNode>) @ 0x00000000168b5cb3
20. src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:165: DB::buildQueryTreeAndRunPasses(std::shared_ptr<DB::IAST> const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::Context const> const&, std::shared_ptr<DB::IStorage> const&) @ 0x000000001727c607
21. src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:182: DB::InterpreterSelectQueryAnalyzer::InterpreterSelectQueryAnalyzer(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const> const&, DB::SelectQueryOptions const&, std::vector<String, std::allocator<String>> const&) @ 0x000000001727adad
22. contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:634: std::__unique_if<DB::InterpreterSelectQueryAnalyzer>::__unique_single std::make_unique[abi:se190107]<DB::InterpreterSelectQueryAnalyzer, std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::Context> const&, DB::SelectQueryOptions const&>(std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::Context> const&, DB::SelectQueryOptions const&) @ 0x000000001727d850
23. contrib/llvm-project/libcxx/include/__functional/function.h:716: ? @ 0x0000000017214144
24. src/Interpreters/executeQuery.cpp:1454: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*, std::shared_ptr<DB::IAST>&) @ 0x000000001754b3c0
25. src/Interpreters/executeQuery.cpp:1714: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x0000000017545eb1
26. src/Client/LocalConnection.cpp:263: DB::LocalConnection::sendQuery(DB::ConnectionTimeouts const&, String const&, std::unordered_map<String, String, std::hash<String>, std::equal_to<String>, std::allocator<std::pair<String const, String>>> const&, String const&, unsigned long, DB::Settings const*, DB::ClientInfo const*, bool, std::vector<String, std::allocator<String>> const&, std::function<void (DB::Progress const&)>) @ 0x00000000191d174f
27. src/Client/ClientBase.cpp:1255: DB::ClientBase::processOrdinaryQuery(String, std::shared_ptr<DB::IAST>) @ 0x000000001916fbb8
28. src/Client/ClientBase.cpp:2274: DB::ClientBase::processParsedSingleQuery(std::basic_string_view<char, std::char_traits<char>>, std::shared_ptr<DB::IAST>, bool&, unsigned long) @ 0x000000001916dffd
29. src/Client/ClientBase.cpp:2646: DB::ClientBase::executeMultiQuery(String const&) @ 0x00000000191794d9
30. src/Client/ClientBase.cpp:2833: DB::ClientBase::processQueryText(String const&) @ 0x000000001917a5fb
31. src/Client/ClientBase.cpp:3388: DB::ClientBase::runInteractive() @ 0x0000000019181aeb

Metadata

Metadata

Assignees

Labels

analyzerIssues and pull-requests related to new analyzerfuzzProblem found by one of the fuzzers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions