Skip to content

Logical error: 'Bad cast from type DB::ColumnSparse to DB::ColumnNullable' with sparse Tuple elements #91284

@PedroTadim

Description

@PedroTadim

Describe the bug

Seen here: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=91227&sha=d04126445a2628f266b8d7a058dac88ca54eb558&name_0=PR&name_1=BuzzHouse%20%28amd_tsan%29 cc @Avogar seems not related to any of other issues.

How to reproduce

It can be reduced further I think. On a debug build run:

CREATE TABLE t0 (c0 JSON, c1 Tuple(Nullable(Int))) ENGINE = MergeTree() ORDER BY tuple();
INSERT INTO TABLE t0 (c0) SELECT '{"c0":1}' FROM numbers(142);
INSERT INTO TABLE t0 (c0) VALUES ('{"a":1}');
ALTER TABLE t0 CLEAR COLUMN c0;
INSERT INTO TABLE t0 (c0) VALUES ('{}');
INSERT INTO TABLE t0 (c0) VALUES ('{}');
INSERT INTO TABLE t0 (c0) VALUES ('{"c0":2}');
INSERT INTO TABLE t0 (c0) SELECT '{}' FROM numbers(196);

Error message and/or stacktrace

Stack trace:

<Fatal> : Logical error: 'Bad cast from type DB::ColumnSparse to DB::ColumnNullable'.
<Fatal> : Stack trace (when copying this message, always include the lines below):

0. contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x0000000025978af2
1. src/Common/Exception.cpp:129: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000015c6dfe9
2. src/Common/Exception.h:123: DB::Exception::Exception(String&&, int, String, bool) @ 0x000000000d9a9ace
3. src/Common/Exception.h:58: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000d9a9611
4. src/Common/Exception.h:141: DB::Exception::Exception<String, String>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<String>::type>, String&&, String&&) @ 0x000000000d9a7976
5. src/Common/assert_cast.h:48: DB::ColumnNullable const& assert_cast<DB::ColumnNullable const&, DB::IColumn const&>(DB::IColumn const&) @ 0x000000000ee21fce
6. src/DataTypes/Serializations/SerializationNullable.cpp:30: DB::SerializationNullable::enumerateStreams(DB::ISerialization::EnumerateStreamsSettings&, std::function<void (DB::ISerialization::SubstreamPath const&)> const&, DB::ISerialization::SubstreamData const&) const @ 0x000000001ad48a52
7. src/DataTypes/Serializations/SerializationNamed.cpp:32: DB::SerializationNamed::enumerateStreams(DB::ISerialization::EnumerateStreamsSettings&, std::function<void (DB::ISerialization::SubstreamPath const&)> const&, DB::ISerialization::SubstreamData const&) const @ 0x000000001ad475d3
8. src/DataTypes/Serializations/SerializationTuple.cpp:702: DB::SerializationTuple::enumerateStreams(DB::ISerialization::EnumerateStreamsSettings&, std::function<void (DB::ISerialization::SubstreamPath const&)> const&, DB::ISerialization::SubstreamData const&) const @ 0x000000001adcfc49
9. src/DataTypes/Serializations/ISerialization.cpp:185: DB::ISerialization::enumerateStreams(std::function<void (DB::ISerialization::SubstreamPath const&)> const&, std::shared_ptr<DB::IDataType const> const&, COW<DB::IColumn>::immutable_ptr<DB::IColumn> const&) const @ 0x000000001acc677f
10. src/Interpreters/inplaceBlockConversions.cpp:307: DB::fillMissingColumns(std::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn>>>&, unsigned long, DB::NamesAndTypesList const&, DB::NamesAndTypesList const&, std::unordered_set<String, std::hash<String>, std::equal_to<String>, std::allocator<String>> const&, std::shared_ptr<DB::StorageInMemoryMetadata const>) @ 0x000000001c0d018e
11. src/Storages/MergeTree/IMergeTreeReader.cpp:146: DB::IMergeTreeReader::fillMissingColumns(std::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn>>>&, bool&, unsigned long) const @ 0x000000001ed5c2e6
12. src/Storages/MergeTree/MergeTreeReadersChain.cpp:139: DB::MergeTreeReadersChain::executeActionsBeforePrewhere(DB::MergeTreeRangeReader::ReadResult&, std::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn>>>&, DB::MergeTreeRangeReader&, DB::Block const&, unsigned long) const @ 0x000000001f031ff2
13. src/Storages/MergeTree/MergeTreeReadersChain.cpp:86: DB::MergeTreeReadersChain::read(unsigned long, DB::MarkRanges&, std::vector<DB::MarkRanges, std::allocator<DB::MarkRanges>>&) @ 0x000000001f03151e
14. src/Storages/MergeTree/MergeTreeSequentialSource.cpp:225: DB::MergeTreeSequentialSource::generate() @ 0x000000001f022f89
15. src/Processors/ISource.cpp:144: DB::ISource::tryGenerate() @ 0x000000001f6b50e5
16. src/Processors/ISource.cpp:110: DB::ISource::work() @ 0x000000001f6b4dc2
17. src/Processors/Executors/ExecutionThreadContext.cpp:53: DB::ExecutionThreadContext::executeTask() @ 0x000000001f6d05b0
18. src/Processors/Executors/PipelineExecutor.cpp:351: DB::PipelineExecutor::executeStepImpl(unsigned long, DB::IAcquiredSlot*, std::atomic<bool>*) @ 0x000000001f6c30d8
19. src/Processors/Executors/PipelineExecutor.cpp:179: DB::PipelineExecutor::executeStep(std::atomic<bool>*) @ 0x000000001f6c2c8e
20. src/Processors/Executors/PullingPipelineExecutor.cpp:59: DB::PullingPipelineExecutor::pull(DB::Chunk&) @ 0x000000001f6d90b4
21. src/Processors/Executors/PullingPipelineExecutor.cpp:70: DB::PullingPipelineExecutor::pull(DB::Block&) @ 0x000000001f6d9243
22. src/Storages/MergeTree/MergeTask.cpp:1007: DB::MergeTask::ExecuteAndFinalizeHorizontalPart::executeImpl() const @ 0x000000001edb6f30
23. src/Storages/MergeTree/MergeTask.cpp:826: DB::MergeTask::ExecuteAndFinalizeHorizontalPart::execute() @ 0x000000001edb5c99
24. src/Storages/MergeTree/MergeTask.cpp:1657: DB::MergeTask::execute() @ 0x000000001edbca76
25. src/Storages/MergeTree/MergePlainMergeTreeTask.cpp:59: DB::MergePlainMergeTreeTask::executeStep() @ 0x000000001eda564e
26. src/Storages/MergeTree/MergeTreeBackgroundExecutor.h:74: DB::TaskRuntimeData::executeStep() const @ 0x000000001ede8a9c
27. src/Storages/MergeTree/MergeTreeBackgroundExecutor.cpp:358: DB::MergeTreeBackgroundExecutor<DB::DynamicRuntimeQueue>::routine(std::shared_ptr<DB::TaskRuntimeData>) @ 0x000000001eded53f
28. src/Storages/MergeTree/MergeTreeBackgroundExecutor.cpp:423: DB::MergeTreeBackgroundExecutor<DB::DynamicRuntimeQueue>::threadFunction() @ 0x000000001edef833
29. contrib/llvm-project/libcxx/include/__functional/function.h:508: ? @ 0x0000000015dbadf6
30. contrib/llvm-project/libcxx/include/__type_traits/invoke.h:217: ThreadFromGlobalPoolImpl<false, true>::ThreadFromGlobalPoolImpl<void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool::*)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool*>(void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool::*&&)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool*&&)::'lambda'()::operator()() @ 0x0000000015dc11a6
31. contrib/llvm-project/libcxx/include/__functional/function.h:508: ? @ 0x0000000015db8232

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official releasefuzzProblem found by one of the fuzzers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions