Skip to content

LOGICAL_ERROR: Expected JOIN table expression to be table, table function, query or union node. Actual ANY LEFT JOIN ... ON k1 = mem.k #84771

@serxa

Description

@serxa

Describe the bug

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=84743&sha=c962f1265511709047c639a74b2f94f728924e4a&name_0=PR&name_1=Stateless%20tests%20%28amd_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29

The following query from 03208_multiple_joins_with_storage_join throws an exception:

SELECT *
FROM tab
ANY LEFT JOIN mem ON k1 = mem.k
ANY RIGHT JOIN mem2 ON k2 = mem2.k
ORDER BY tab.v;

How to reproduce

No response

Error message and/or stacktrace

clickhouse-server.err.log:2025.07.30 21:17:59.109145 [ 95158 ] {a866cb78-d8fa-4cbe-b76e-420541c782c1} <Error> executeQuery: Code: 49. DB::Exception: Expected JOIN table expression to be table, table function, query or union node. Actual  ANY LEFT JOIN ... ON k1 = mem.k. (LOGICAL_ERROR) (version 25.8.1.1957 (official build)) (from [::1]:47948) (comment: 03208_multiple_joins_with_storage_join.sql) (query 20, line 36) (in query: SELECT * FROM tab ANY LEFT JOIN mem ON k1 = mem.k ANY RIGHT JOIN mem2 ON k2 = mem2.k ORDER BY tab.v ;), Stack trace (when copying this message, always include the lines below):
clickhouse-server.err.log-
clickhouse-server.err.log-0. ./contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x000000001ebbb432
clickhouse-server.err.log-1. ./ci/tmp/build/./src/Common/Exception.cpp:115: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000f8006db
clickhouse-server.err.log-2. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000008e0502c
clickhouse-server.err.log-3. DB::Exception::Exception<String>(int, FormatStringHelperImpl<std::type_identity<String>::type>, String&&) @ 0x0000000008e04ceb
clickhouse-server.err.log-4. ./ci/tmp/build/./src/Storages/buildQueryTreeForShard.cpp:353: DB::buildQueryTreeForShard(std::shared_ptr<DB::PlannerContext> const&, std::shared_ptr<DB::IQueryTreeNode>, bool) @ 0x000000001825ec1f
clickhouse-server.err.log-5. ./ci/tmp/build/./src/Interpreters/ClusterProxy/executeQuery.cpp:769: DB::ClusterProxy::executeQueryWithParallelReplicas(DB::QueryPlan&, DB::StorageID const&, DB::QueryProcessingStage::Enum, std::shared_ptr<DB::IQueryTreeNode> const&, std::shared_ptr<DB::PlannerContext> const&, std::shared_ptr<DB::Context const>, std::shared_ptr<std::list<DB::StorageLimits, std::allocator<DB::StorageLimits>> const>, std::unique_ptr<DB::IQueryPlanStep, std::default_delete<DB::IQueryPlanStep>>) @ 0x00000000179cee0a
clickhouse-server.err.log-6. ./ci/tmp/build/./src/Planner/PlannerJoinTree.cpp:1182: DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr<DB::IQueryTreeNode>, std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::PlannerContext>&, bool, bool) @ 0x0000000014f9a259
clickhouse-server.err.log-7. ./ci/tmp/build/./src/Planner/PlannerJoinTree.cpp:2409: DB::buildJoinTreeQueryPlan(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::PlannerContext>&) @ 0x0000000014f902ec
clickhouse-server.err.log-8. ./ci/tmp/build/./src/Planner/Planner.cpp:1616: DB::Planner::buildPlanForQueryNode() @ 0x0000000014f78e55
--

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed user-visible misbehaviour in official releasefuzzProblem 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