ClickHouse / ClickHouse

ClickHouse® is a real-time analytics DBMS
https://clickhouse.com
Apache License 2.0
37.48k stars 6.89k forks source link

[Maybe a bug]BAD_GET: "Bad get: has Decimal128, requested Decimal64" #69391

Closed LGDHuaOPER closed 1 month ago

LGDHuaOPER commented 1 month ago

Company or project name

No response

Question

The version 24.9.1.41 and version 24.8.4.13 all have this issue. And the version 24.4 and version 24.5 I used before did not have this issue.

I found error when using query:

SELECT maxMapState([op], [toDateTime64(process_end_time, 3, 'Asia/Shanghai')]) AS op_recent_time_map AS op_recent_time_map FROM my_table

The error is:

2024.09.08 10:54:42.199082 [ 35526 ] {} <Error> void DB::StorageBuffer::backgroundFlush(): Code: 170. DB::Exception: Bad get: has Decimal128, requested Decimal64: while pushing to view eos_alogger.user_bucket_stats_activity_metrics_mv (2fdccd04-24db-4325-8f79-1d38d1bba45b): while pushing to view eos_alogger.accesser_access_log_business_mv (0730b913-93ed-4802-bebd-c7c599e9e6a8). (BAD_GET), Stack trace (when copying this message, always include the lines below):

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000db87cdb
1. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000007e8114c
2. DB::Exception::Exception<std::basic_string_view<char, std::char_traits<char>>, DB::Field::Types::Which const&>(int, FormatStringHelperImpl<std::type_identity<std::basic_string_view<char, std::char_traits<char>>>::type, std::type_identity<DB::Field::Types::Which const&>::type>, std::basic_string_view<char, std::char_traits<char>>&&, DB::Field::Types::Which const&) @ 0x0000000007e8a50b
3. auto& DB::Field::safeGet<DB::DecimalField<DB::DateTime64>>() @ 0x00000000095094f0
4. DB::SerializationDecimalBase<DB::DateTime64>::serializeBinary(DB::Field const&, DB::WriteBuffer&, DB::FormatSettings const&) const @ 0x0000000007a34a30
5. void std::__function::__policy_invoker<void (unsigned long, DB::Array const&)>::__call_impl<std::__function::__default_alloc_func<DB::(anonymous namespace)::AggregateFunctionMapBase<DB::(anonymous namespace)::AggregateFunctionMaxMap<false>, DB::(anonymous namespace)::FieldVisitorMax, true, false, false>::serialize(char const*, DB::WriteBuffer&, std::optional<unsigned long>) const::'lambda0'(unsigned long, DB::Array const&), void (unsigned long, DB::Array const&)>>(std::__function::__policy_storage const*, unsigned long, DB::Array const&) @ 0x000000000ff5bfca
6. DB::(anonymous namespace)::AggregateFunctionMapBase<DB::(anonymous namespace)::AggregateFunctionMaxMap<false>, DB::(anonymous namespace)::FieldVisitorMax, true, false, false>::serialize(char const*, DB::WriteBuffer&, std::optional<unsigned long>) const (.57d3f6c10521af555a2cc605b00052ac) @ 0x000000000ff5964d
7. DB::SerializationAggregateFunction::serializeBinaryBulk(DB::IColumn const&, DB::WriteBuffer&, unsigned long, unsigned long) const @ 0x000000001123eddd
8. DB::ISerialization::serializeBinaryBulkWithMultipleStreams(DB::IColumn const&, unsigned long, unsigned long, DB::ISerialization::SerializeBinaryBulkSettings&, std::shared_ptr<DB::ISerialization::SerializeBinaryBulkState>&) const @ 0x0000000011238f66
9. DB::MergeTreeDataPartWriterCompact::writeDataBlockPrimaryIndexAndSkipIndices(DB::Block const&, std::vector<DB::Granule, std::allocator<DB::Granule>> const&) @ 0x0000000012b5739e
10. DB::MergeTreeDataPartWriterCompact::fillChecksums(DB::MergeTreeDataPartChecksums&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>>&) @ 0x0000000012b58344
11. DB::MergedBlockOutputStream::finalizePartAsync(std::shared_ptr<DB::IMergeTreeDataPart> const&, bool, DB::NamesAndTypesList const*, DB::MergeTreeDataPartChecksums*) @ 0x0000000012cacb6f
12. DB::MergeTreeDataWriter::writeTempPartImpl(DB::BlockWithPartition&, std::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::shared_ptr<DB::Context const>, long, bool) @ 0x0000000012b9cc0c
13. DB::MergeTreeSink::consume(DB::Chunk&) @ 0x0000000012e3a91c
14. DB::SinkToStorage::onConsume(DB::Chunk) @ 0x00000000134702c4
15. void std::__function::__policy_invoker<void ()>::__call_impl<std::__function::__default_alloc_func<DB::ExceptionKeepingTransform::work()::$_1, void ()>>(std::__function::__policy_storage const*) @ 0x00000000133a7bb8
16. DB::runStep(std::function<void ()>, DB::ThreadStatus*, std::atomic<unsigned long>*) @ 0x00000000133a78cb
17. DB::ExceptionKeepingTransform::work() @ 0x00000000133a70f5
18. DB::ExecutionThreadContext::executeTask() @ 0x0000000013134cc7
19. DB::PipelineExecutor::executeStepImpl(unsigned long, std::atomic<bool>*) @ 0x0000000013128790
20. DB::PipelineExecutor::executeStep(std::atomic<bool>*) @ 0x0000000013128188
21. DB::StorageBuffer::writeBlockToDestination(DB::Block const&, std::shared_ptr<DB::IStorage>) @ 0x00000000127c4cd3
22. DB::StorageBuffer::flushBuffer(DB::StorageBuffer::Buffer&, bool, bool) @ 0x00000000127c1890
23. DB::ThreadPoolCallbackRunnerLocal<void, ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>, std::function<void ()>>::operator()(std::function<void ()>&&, Priority)::'lambda'()::operator()() @ 0x000000001081b4e8
24. std::packaged_task<void ()>::operator()() @ 0x000000000e13320c
25. ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::worker(std::__list_iterator<ThreadFromGlobalPoolImpl<false, true>, void*>) @ 0x000000000dc5ddf8
26. void std::__function::__policy_invoker<void ()>::__call_impl<std::__function::__default_alloc_func<ThreadFromGlobalPoolImpl<false, true>::ThreadFromGlobalPoolImpl<void ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>(void&&)::'lambda'(), void ()>>(std::__function::__policy_storage const*) @ 0x000000000dc62f31
27. void* std::__thread_proxy[abi:v15007]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>>(void*) @ 0x000000000dc6135f
28. ? @ 0x00007f3354625609
29. ? @ 0x00007f335454a353
 (version 24.9.1.41 (official build))

When I use this query:

SELECT maxMapState([op], [toDateTime(process_end_time, 'Asia/Shanghai')]) AS op_recent_time_map AS op_recent_time_map FROM my_table

It is OK.

Thanks!

al13n321 commented 1 month ago

Reproduces with just

SELECT maxMapState([0], [toDateTime64(0, 0)])