Skip to content

Analyzer: Implicit table function file doesn't work. Database _table_function does not exist #74424

@Algunenano

Description

@Algunenano

Running under CH local with a file as source:

SELECT *
FROM `query_log.tsv.zst`
WHERE query_duration_ms = (
    SELECT max(query_duration_ms)
    FROM `query_log.tsv.zst`
    WHERE query LIKE 'ALTER TABLE src%'
)
LIMIT 1

Works fine with the old analyzer. Fails with the new one:

2025.01.10 12:21:50.127460 [ 384313 ] {f0dfbd5f-a35c-4078-a8ec-adabe7a05b25} <Error> executeQuery: Code: 81. DB::Exception: Database _table_function does not exist. (UNKNOWN_DATABASE) (version 25.1.1.1) (from 0.0.0.0:0) (in query: Select * from 'query_log.tsv.zst' WHERE query_duration_ms = (Select max(query_duration_ms) FROM 'query_log.tsv.zst' WHERE query like 'ALTER TABLE src%') limit 1 ), Stack trace (when copying this message, always include the lines below):

0. /mnt/ch/ClickHouse/contrib/llvm-project/libcxx/include/__exception/exception.h:106: Poco::Exception::Exception(String const&, int) @ 0x00000000173473eb
1. /mnt/ch/ClickHouse/src/Common/Exception.cpp:105: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c75bb67
2. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000006f45c7a
3. DB::Exception::Exception<String>(int, FormatStringHelperImpl<std::type_identity<String>::type>, String&&) @ 0x0000000006f458bb
4. /mnt/ch/ClickHouse/src/Interpreters/DatabaseCatalog.cpp:663: DB::DatabaseCatalog::getDatabase(String const&) const @ 0x0000000011a8e1cb
5. /mnt/ch/ClickHouse/src/Interpreters/Context.cpp:5439: DB::Context::resolveStorageID(DB::StorageID, DB::Context::StorageNamespace) const @ 0x00000000119c3c5d
6. /mnt/ch/ClickHouse/src/Analyzer/Resolve/IdentifierResolver.cpp:418: DB::IdentifierResolver::tryResolveTableIdentifierFromDatabaseCatalog(DB::Identifier const&, std::shared_ptr<DB::Context const>) @ 0x000000001181574a
7. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:1532: DB::QueryAnalyzer::tryResolveIdentifier(DB::IdentifierLookup const&, DB::IdentifierResolveScope&, DB::IdentifierResolveSettings) @ 0x00000000117cc3b4
8. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:4398: DB::QueryAnalyzer::initializeQueryJoinTreeNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&) @ 0x00000000117e5823
9. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:5615: DB::QueryAnalyzer::resolveQuery(std::shared_ptr<DB::IQueryTreeNode> const&, DB::IdentifierResolveScope&) @ 0x00000000117b7cd6
10. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:174: DB::QueryAnalyzer::resolve(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::IQueryTreeNode> const&, std::shared_ptr<DB::Context const>) @ 0x00000000117b70ec
11. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalysisPass.cpp:18: DB::QueryAnalysisPass::run(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::Context const>) @ 0x00000000117b6927
12. /mnt/ch/ClickHouse/src/Analyzer/QueryTreePassManager.cpp:184: DB::QueryTreePassManager::run(std::shared_ptr<DB::IQueryTreeNode>) @ 0x0000000011e6a063
13. /mnt/ch/ClickHouse/src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:149: DB::(anonymous namespace)::buildQueryTreeAndRunPasses(std::shared_ptr<DB::IAST> const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::Context const> const&, std::shared_ptr<DB::IStorage> const&) @ 0x00000000120cda1e
14. /mnt/ch/ClickHouse/src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:181: DB::InterpreterSelectQueryAnalyzer::InterpreterSelectQueryAnalyzer(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const> const&, std::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::vector<String, std::allocator<String>> const&) @ 0x00000000120cdba5
15. /mnt/ch/ClickHouse/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:597: std::__unique_if<DB::InterpreterSelectQueryAnalyzer>::__unique_single std::make_unique[abi:ne180100]<DB::InterpreterSelectQueryAnalyzer, std::shared_ptr<DB::IAST>, std::shared_ptr<DB::Context>&, std::shared_ptr<DB::IStorage>, DB::SelectQueryOptions&>(std::shared_ptr<DB::IAST>&&, std::shared_ptr<DB::Context>&, std::shared_ptr<DB::IStorage>&&, DB::SelectQueryOptions&) @ 0x00000000117eae75
16. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:588: DB::QueryAnalyzer::evaluateScalarSubqueryIfNeeded(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&) @ 0x00000000117c4aa5
17. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:3890: DB::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, bool, bool, bool) @ 0x00000000117be7a3
18. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:4013: DB::QueryAnalyzer::resolveExpressionNodeList(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, bool, bool) @ 0x00000000117bd620
19. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:2912: DB::QueryAnalyzer::resolveFunction(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&) @ 0x00000000117d2c52
20. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:3853: DB::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::IdentifierResolveScope&, bool, bool, bool) @ 0x00000000117be3ee
21. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:5654: DB::QueryAnalyzer::resolveQuery(std::shared_ptr<DB::IQueryTreeNode> const&, DB::IdentifierResolveScope&) @ 0x00000000117b7f44
22. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalyzer.cpp:174: DB::QueryAnalyzer::resolve(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::IQueryTreeNode> const&, std::shared_ptr<DB::Context const>) @ 0x00000000117b70ec
23. /mnt/ch/ClickHouse/src/Analyzer/Resolve/QueryAnalysisPass.cpp:18: DB::QueryAnalysisPass::run(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::Context const>) @ 0x00000000117b6927
24. /mnt/ch/ClickHouse/src/Analyzer/QueryTreePassManager.cpp:184: DB::QueryTreePassManager::run(std::shared_ptr<DB::IQueryTreeNode>) @ 0x0000000011e6a063
25. /mnt/ch/ClickHouse/src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:149: DB::(anonymous namespace)::buildQueryTreeAndRunPasses(std::shared_ptr<DB::IAST> const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::Context const> const&, std::shared_ptr<DB::IStorage> const&) @ 0x00000000120cda1e
26. /mnt/ch/ClickHouse/src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:167: 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&) @ 0x00000000120cbb09
27. /mnt/ch/ClickHouse/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:597: std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> std::__function::__policy_invoker<std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> (DB::InterpreterFactory::Arguments const&)>::__call_impl[abi:ne180100]<std::__function::__default_alloc_func<DB::registerInterpreterSelectQueryAnalyzer(DB::InterpreterFactory&)::$_0, std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> (DB::InterpreterFactory::Arguments const&)>>(std::__function::__policy_storage const*, DB::InterpreterFactory::Arguments const&) @ 0x00000000120cea10
28. /mnt/ch/ClickHouse/contrib/llvm-project/libcxx/include/__functional/function.h:714: ? @ 0x000000001206c999
29. /mnt/ch/ClickHouse/src/Interpreters/executeQuery.cpp:1378: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x000000001242c0be
30. /mnt/ch/ClickHouse/src/Interpreters/executeQuery.cpp:1608: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x000000001242888b
31. /mnt/ch/ClickHouse/src/Client/LocalConnection.cpp:252: 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&)>) @ 0x0000000013c1e606


Elapsed: 0.001 sec. 

Metadata

Metadata

Labels

analyzerIssues and pull-requests related to new analyzerbugConfirmed user-visible misbehaviour in official releasefuzzProblem found by one of the fuzzersst-fixedThe problem is fixed, but pending a test.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions