-
Notifications
You must be signed in to change notification settings - Fork 8.3k
UNSUPPORTED_METHOD for WITH statement with the production analyzer #63239
Copy link
Copy link
Closed
Labels
analyzerIssues and pull-requests related to new analyzerIssues and pull-requests related to new analyzeranalyzer-importantbugConfirmed user-visible misbehaviour in official releaseConfirmed user-visible misbehaviour in official release
Description
ClickHouse version 24.4.1.2088
Describe what's wrong
WITH statement stopped working with UNSUPPORTED_METHOD. Probably a bug in beta analyzer:
https://fiddle.clickhouse.com/d36accf5-2e87-476f-b9e7-f2f5b7c746fd
Expected behavior
The WITH statement should work the same on both analyzers.
Error message and/or stacktrace
[cac8ec3c560a] 2024.05.01 14:27:23.425533 [ 48 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Debug> executeQuery: (from 127.0.0.1:38868) WITH Block_Height BETWEEN 1 AND 2 AS block_filter SELECT * FROM test WHERE block_filter AND ( Block_Date IN ( SELECT Block_Date FROM test WHERE block_filter ) ) SETTINGS allow_experimental_analyzer = false; (stage: Complete)
[cac8ec3c560a] 2024.05.01 14:27:23.426251 [ 48 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Trace> ContextAccess (default): Access granted: SELECT(Block_Height, Block_Date) ON default.test
[cac8ec3c560a] 2024.05.01 14:27:23.426337 [ 48 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Trace> InterpreterSelectQuery: FetchColumns -> Complete
[cac8ec3c560a] 2024.05.01 14:27:23.426480 [ 48 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Trace> ContextAccess (default): Access granted: SELECT(a, b, Block_Height, Block_Date) ON default.test
[cac8ec3c560a] 2024.05.01 14:27:23.426538 [ 48 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Trace> InterpreterSelectQuery: FetchColumns -> Complete
[cac8ec3c560a] 2024.05.01 14:27:23.427962 [ 718 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Trace> CreatingSetsTransform: Creating set, key: __set_15181162166609052100_13383299000571546906
[cac8ec3c560a] 2024.05.01 14:27:23.428024 [ 718 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Debug> CreatingSetsTransform: Subquery has empty result.
[cac8ec3c560a] 2024.05.01 14:27:23.429282 [ 48 ] {a7d2aef8-abdb-4365-8377-6080ae86fcfb} <Debug> TCPHandler: Processed in 0.004043954 sec.
[cac8ec3c560a] 2024.05.01 14:27:23.430255 [ 48 ] {4f56781f-8214-47e0-ba42-391ecba97888} <Debug> executeQuery: (from 127.0.0.1:38868) SELECT 'THIS WORKS ---'; (stage: Complete)
[cac8ec3c560a] 2024.05.01 14:27:23.430397 [ 48 ] {4f56781f-8214-47e0-ba42-391ecba97888} <Trace> Planner: Query SELECT 'THIS WORKS ---' AS `'THIS WORKS ---'` FROM system.one AS __table1 to stage Complete
[cac8ec3c560a] 2024.05.01 14:27:23.430426 [ 48 ] {4f56781f-8214-47e0-ba42-391ecba97888} <Trace> ContextAccess (default): Access granted: SELECT(dummy) ON system.one
[cac8ec3c560a] 2024.05.01 14:27:23.430476 [ 48 ] {4f56781f-8214-47e0-ba42-391ecba97888} <Trace> Planner: Query SELECT 'THIS WORKS ---' AS `'THIS WORKS ---'` FROM system.one AS __table1 from stage FetchColumns to stage Complete
[cac8ec3c560a] 2024.05.01 14:27:23.430927 [ 48 ] {4f56781f-8214-47e0-ba42-391ecba97888} <Debug> executeQuery: Read 1 rows, 1.00 B in 0.000681 sec., 1468.4287812041116 rows/sec., 1.43 KiB/sec.
[cac8ec3c560a] 2024.05.01 14:27:23.430971 [ 48 ] {4f56781f-8214-47e0-ba42-391ecba97888} <Debug> TCPHandler: Processed in 0.000912421 sec.
[cac8ec3c560a] 2024.05.01 14:27:23.431756 [ 48 ] {ddea44dc-7fd0-4a42-8f4c-be3f2995af6c} <Debug> executeQuery: (from 127.0.0.1:38868) WITH Block_Height BETWEEN 1 AND 2 AS block_filter SELECT * FROM test WHERE block_filter AND ( Block_Date IN ( SELECT Block_Date FROM test WHERE block_filter ) ); (stage: Complete)
[cac8ec3c560a] 2024.05.01 14:27:23.432705 [ 48 ] {ddea44dc-7fd0-4a42-8f4c-be3f2995af6c} <Error> executeQuery: Code: 1. DB::Exception: Resolve identifier 'block_filter' from parent scope only supported for constants and CTE. Actual (Block_Height >= 1) AND (Block_Height <= 2) AS block_filter node type FUNCTION. In scope (SELECT Block_Date FROM test WHERE block_filter). (UNSUPPORTED_METHOD) (version 24.4.1.2088 (official build)) (from 127.0.0.1:38868) (in query: WITH Block_Height BETWEEN 1 AND 2 AS block_filter SELECT * FROM test WHERE block_filter AND ( Block_Date IN ( SELECT Block_Date FROM test WHERE block_filter ) );), Stack trace (when copying this message, always include the lines below):
0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c9a449b
1. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000780b9ac
2. DB::Exception::Exception<String const&, String, char const*, String>(int, FormatStringHelperImpl<std::type_identity<String const&>::type, std::type_identity<String>::type, std::type_identity<char const*>::type, std::type_identity<String>::type>, String const&, String&&, char const*&&, String&&) @ 0x0000000010ac0e4f
3. DB::(anonymous namespace)::QueryAnalyzer::tryResolveIdentifier(DB::(anonymous namespace)::IdentifierLookup const&, DB::(anonymous namespace)::IdentifierResolveScope&, DB::(anonymous namespace)::IdentifierResolveSettings) @ 0x0000000010a95f53
4. DB::(anonymous namespace)::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 0x0000000010a84eb8
5. DB::(anonymous namespace)::QueryAnalyzer::resolveQuery(std::shared_ptr<DB::IQueryTreeNode> const&, DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x0000000010a7a7d6
6. DB::(anonymous namespace)::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 0x0000000010a84933
7. DB::(anonymous namespace)::QueryAnalyzer::resolveExpressionNodeList(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 0x0000000010a831ed
8. DB::(anonymous namespace)::QueryAnalyzer::resolveFunction(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x0000000010a9d957
9. DB::(anonymous namespace)::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 0x0000000010a841bc
10. DB::(anonymous namespace)::QueryAnalyzer::resolveExpressionNodeList(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 0x0000000010a831ed
11. DB::(anonymous namespace)::QueryAnalyzer::resolveFunction(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x0000000010a9d957
12. DB::(anonymous namespace)::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&, DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 0x0000000010a841bc
13. DB::(anonymous namespace)::QueryAnalyzer::resolveQuery(std::shared_ptr<DB::IQueryTreeNode> const&, DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x0000000010a7a7d6
14. DB::QueryAnalysisPass::run(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::Context const>) @ 0x0000000010a780c5
15. DB::QueryTreePassManager::run(std::shared_ptr<DB::IQueryTreeNode>) @ 0x0000000010a76983
16. 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&) (.llvm.9862110563685019565) @ 0x0000000010d0aafd
17. DB::InterpreterSelectQueryAnalyzer::InterpreterSelectQueryAnalyzer(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const> const&, DB::SelectQueryOptions const&) @ 0x0000000010d09899
18. 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<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&) (.llvm.9862110563685019565) @ 0x0000000010d0c86c
19. DB::InterpreterFactory::get(std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::Context>, DB::SelectQueryOptions const&) @ 0x0000000010c9ec79
20. DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x000000001111a030
21. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x00000000111169ba
22. DB::TCPHandler::runImpl() @ 0x00000000122a59c4
23. DB::TCPHandler::run() @ 0x00000000122c1fb9
24. Poco::Net::TCPServerConnection::start() @ 0x0000000014c105b2
25. Poco::Net::TCPServerDispatcher::run() @ 0x0000000014c113f9
26. Poco::PooledThread::run() @ 0x0000000014d09a61
27. Poco::ThreadImpl::runnableEntry(void*) @ 0x0000000014d07ffd
28. ? @ 0x000077fa4d433609
29. ? @ 0x000077fa4d34e353
Received exception from server (version 24.4.1):
Code: 1. DB::Exception: Received from localhost:9000. DB::Exception: Resolve identifier 'block_filter' from parent scope only supported for constants and CTE. Actual (Block_Height >= 1) AND (Block_Height <= 2) AS block_filter node type FUNCTION. In scope (SELECT Block_Date FROM test WHERE block_filter). (UNSUPPORTED_METHOD)
(query: WITH Block_Height BETWEEN 1 AND 2 AS block_filter
SELECT *
FROM test
WHERE block_filter
AND (
Block_Date IN (
SELECT Block_Date FROM test WHERE block_filter
)
);)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
analyzerIssues and pull-requests related to new analyzerIssues and pull-requests related to new analyzeranalyzer-importantbugConfirmed user-visible misbehaviour in official releaseConfirmed user-visible misbehaviour in official release