Skip to content

DB::Exception: Key expression contains comparison between inconvertible types: DateTime and Int64 #8550

@yuzhichang

Description

@yuzhichang

Describe the bug or unexpected behaviour*
The DELETE mutation sql succeeded before, however failed with an exception this morning.

How to reproduce

  • Which ClickHouse server version to use
    ClickHouse server version 19.15.3 revision 54426.
  • Which interface to use, if matters
    CLI
  • CREATE TABLE statements for all tables involved
# less metadata/default/cdp_orders.sql:
ATTACH TABLE cdp_orders
(
    `order_id` String, 
    `order_status` String, 
    `order_time` DateTime, 
...
)
ENGINE = ReplacingMergeTree()
PARTITION BY toYYYYMMDD(order_time)
ORDER BY (order_time, order_id)
SETTINGS index_granularity = 8192
  • Queries to run that lead to unexpected result
ALTER TABLE default.cdp_orders DELETE WHERE order_time >= '2019-12-03 00:00:00'

Error message and/or stacktrace

2020.01.07 08:27:59.692347 [ 192 ] {d35ae4a1-a19a-452f-9d27-b652fdc38dbd} <Debug> DDLWorker: Executing query: ALTER TABLE default.cdp_orders DELETE WHERE order_time >= '2019-12-03 00:00:00' 
2020.01.07 08:27:59.692445 [ 192 ] {1f97fa5b-bab3-4a80-8cb7-da1de245060d} <Debug> executeQuery: (from 0.0.0.0:0, user: ) /* ddl_entry=query-0000011064 */ ALTER TABLE default.cdp_orders DELET
E WHERE order_time >= '2019-12-03 00:00:00' 
2020.01.07 08:27:59.699484 [ 192 ] {1f97fa5b-bab3-4a80-8cb7-da1de245060d} <Information> default.cdp_orders: Added mutation: mutation_24405.txt
2020.01.07 08:27:59.699616 [ 192 ] {1f97fa5b-bab3-4a80-8cb7-da1de245060d} <Debug> DDLWorker: Executed query: ALTER TABLE default.cdp_orders DELETE WHERE order_time >= '2019-12-03 00:00:00' 
2020.01.07 08:27:59.700920 [ 192 ] {1f97fa5b-bab3-4a80-8cb7-da1de245060d} <Debug> DDLWorker: Waiting a watch
2020.01.07 08:27:59.703728 [ 3 ] {} <Debug> DiskSpaceMonitor: Reserving 115.57 MiB on disk `default`, having unreserved 480.44 GiB.
2020.01.07 08:27:59.705124 [ 3 ] {} <Error> void DB::BackgroundProcessingPool::threadFunction(): Code: 169, e.displayText() = DB::Exception: Key expression contains comparison between inconv
ertible types: DateTime and Int64 inside order_time >= ((2019 - 12) - 3), Stack trace:

0. 0x555f50f8f4c0 StackTrace::StackTrace() /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Common/StackTrace.cpp:228
1. 0x555f50f8f295 DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../
dbms/src/Common/Exception.h:27
2. 0x555f50dcfcaa DB::KeyCondition::atomFromAST(std::shared_ptr<DB::IAST> const&, DB::Context const&, DB::Block&, DB::KeyCondition::RPNElement&) [clone .cold] /usr/include/c++/9/bits/basic_s
tring.h:222
3. 0x555f544c7f2b DB::KeyCondition::traverseAST(std::shared_ptr<DB::IAST> const&, DB::Context const&, DB::Block&) /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Storages/Merg
eTree/KeyCondition.cpp:453
4. 0x555f544c7ede DB::KeyCondition::traverseAST(std::shared_ptr<DB::IAST> const&, DB::Context const&, DB::Block&) /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Storages/Merg
eTree/KeyCondition.cpp:445
5. 0x555f544c8544 DB::KeyCondition::KeyCondition(DB::SelectQueryInfo const&, DB::Context const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 
std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::shared_ptr<DB::ExpressionActions> const&) /usr/include/c++/9/bits/shared_ptr_b
6. 0x555f545304a7 DB::MergeTreeDataSelectExecutor::readFromParts(std::vector<std::shared_ptr<DB::MergeTreeDataPart const>, std::allocator<std::shared_ptr<DB::MergeTreeDataPart const> > >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, DB::SelectQueryInfo const&, DB::Context const&, unsigned long, unsigned int, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, long> > > const*) const /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp:224
7. 0x555f5450ae2a DB::StorageFromMergeTreeDataPart::read(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, DB::SelectQueryInfo const&, DB::Context const&, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h:32
8. 0x555f5420258f void DB::InterpreterSelectQuery::executeFetchColumns<DB::InterpreterSelectQuery::Pipeline>(DB::QueryProcessingStage::Enum, DB::InterpreterSelectQuery::Pipeline&, std::shared_ptr<DB::SortingInfo> const&, std::shared_ptr<DB::PrewhereInfo> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) /usr/include/c++/9/bits/stl_vector.h:1005
9. 0x555f54208b16 void DB::InterpreterSelectQuery::executeImpl<DB::InterpreterSelectQuery::Pipeline>(DB::InterpreterSelectQuery::Pipeline&, std::shared_ptr<DB::IBlockInputStream> const&) /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Interpreters/InterpreterSelectQuery.cpp:1047
10. 0x555f541eb1a5 DB::InterpreterSelectQuery::execute() /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Interpreters/InterpreterSelectQuery.cpp:394
11. 0x555f5494263d DB::MutationsInterpreter::isStorageTouchedByMutations() const /usr/include/c++/9/bits/shared_ptr_base.h:758
12. 0x555f54507253 DB::MergeTreeDataMergerMutator::mutatePartToTemporaryPart(DB::FutureMergedMutatedPart const&, std::vector<DB::MutationCommand, std::allocator<DB::MutationCommand> > const&
, DB::MergeListEntry&, DB::Context const&, DB::DiskSpace::Reservation*, DB::TableStructureReadLockHolder&) /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp:944
13. 0x555f5442515b DB::StorageMergeTree::tryMutatePart() /usr/include/c++/9/bits/shared_ptr_base.h:1177
14. 0x555f544255db DB::StorageMergeTree::mergeMutateTask() /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Storages/StorageMergeTree.cpp:775
15. 0x555f544b2f84 DB::BackgroundProcessingPool::threadFunction() /usr/include/c++/9/bits/std_function.h:688
16. 0x555f544b38fa ThreadFromGlobalPool::ThreadFromGlobalPool<DB::BackgroundProcessingPool::BackgroundProcessingPool(int)::{lambda()#1}>(DB::BackgroundProcessingPool::BackgroundProcessingPool(int)::{lambda()#1}&&)::{lambda()#1}::operator()() const /bigdata/zhichyu/1/ClickHouse/obj-x86_64-linux-gnu/../dbms/src/Common/ThreadPool.h:150
17. 0x555f50fd842c ThreadPoolImpl<std::thread>::worker(std::_List_iterator<std::thread>) /usr/include/c++/9/bits/atomic_base.h:551
18. 0x555f55adc430 execute_native_thread_routine /usr/lib/debug/usr/bin/clickhouse
19. 0x7fe1b4913e65 start_thread /usr/lib64/libpthread-2.17.so
20. 0x7fe1b423088d __clone /usr/lib64/libc-2.17.so
 (version 19.15.3.6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed user-visible misbehaviour in official releasecomp-ddlDDL command coordination and execution (ON CLUSTER, DDL queue).comp-mutationsALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions