Skip to content

Logical Error: LIMIT WITH TIES without ORDER BY #71756

@PedroTadim

Description

@PedroTadim

Describe the bug
Calling tuple() with ORDER BY and LIMIT gives a logical error

How to reproduce
Run:
https://fiddle.clickhouse.com/2b7cdd96-a7e6-424e-9251-6d403d444bb6

Stack trace:

Logical error: 'LIMIT WITH TIES without ORDER BY'.
Stack trace (when copying this message, always include the lines below):

0. std::exception::capture() @ 0x000000001943cf0b
1. contrib/llvm-project/libcxx/include/exception:114: Poco::Exception::Exception(String const&, int) @ 0x0000000038ce4905
2. src/Common/Exception.cpp:109: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x00000000255a54eb
3. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x00000000192bb296
4. DB::Exception::Exception<>(int, FormatStringHelperImpl<>) @ 0x00000000192d4cef
5. src/Planner/Planner.cpp:1094: DB::(anonymous namespace)::addLimitStep(DB::QueryPlan&, DB::(anonymous namespace)::QueryAnalysisResult const&, std::shared_ptr<DB::PlannerContext> const&, DB::QueryNode const&) @ 0x0000000032586293
6. src/Planner/Planner.cpp:1801: DB::Planner::buildPlanForQueryNode() @ 0x000000003257e887
7. src/Planner/Planner.cpp:1301: DB::Planner::buildQueryPlanIfNeeded() @ 0x00000000325702bb
8. src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:241: DB::InterpreterSelectQueryAnalyzer::getQueryPlan() @ 0x000000003256c76f
9. src/Interpreters/executeQuery.cpp:1346: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x0000000032ae2476
10. src/Interpreters/executeQuery.cpp:1564: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x0000000032adbaf3
11. src/Server/TCPHandler.cpp:595: DB::TCPHandler::runImpl() @ 0x000000003525b9c6
12. src/Server/TCPHandler.cpp:2528: DB::TCPHandler::run() @ 0x00000000352914b6
13. base/poco/Net/src/TCPServerConnection.cpp:43: Poco::Net::TCPServerConnection::start() @ 0x0000000038e35f38
14. base/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x0000000038e37072
15. base/poco/Foundation/src/ThreadPool.cpp:205: Poco::PooledThread::run() @ 0x0000000038d89a61
16. ./base/poco/Foundation/src/Thread_POSIX.cpp:335: Poco::ThreadImpl::runnableEntry(void*) @ 0x0000000038d84a2f
17. ? @ 0x00007ffff7ca1e2e
18. ? @ 0x00007ffff7d33a4c

Metadata

Metadata

Assignees

Labels

analyzerIssues and pull-requests related to new analyzerbugConfirmed 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