Skip to content

Logical error on column type mismatch from SQLite #71263

@PedroTadim

Description

@PedroTadim

Describe the bug
If a Clickhouse UUID column is mapped into SQLite's TEXT type, a logical error happens when fetching the value:

How to reproduce
In SQLite run:

CREATE TABLE t0(c0 TEXT);

Then in Clickhouse run:

CREATE TABLE t0 (c0 UUID) ENGINE = SQLite('<path to sqlite db>', 't0');
INSERT INTO TABLE t0 (c0) VALUES ('f5c9d035-cb46-9811-92c1-169d868ba2db');
SELECT c0 FROM t0; --logical error

Stack trace:

<Fatal> : Logical error: 'Bad cast from type DB::ColumnVector<StrongTypedef<wide::integer<128ul, unsigned int>, DB::UUIDTag>> to DB::ColumnString'.
<Fatal> : Stack trace (when copying this message, always include the lines below):

0. std::exception::capture() @ 0x000000001933ef0b
1. ./contrib/llvm-project/libcxx/include/exception:114: Poco::Exception::Exception(String const&, int) @ 0x0000000038aef885
2. src/Common/Exception.cpp:109: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x00000000254968ab
3. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x00000000191bd296
4. DB::Exception::Exception<String, String>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<String>::type>, String&&, String&&) @ 0x00000000191bf9af
5. DB::ColumnString& assert_cast<DB::ColumnString&, DB::IColumn&>(DB::IColumn&) @ 0x000000001921298b
6. src/Processors/Sources/SQLiteSource.cpp:157: DB::SQLiteSource::insertValue(DB::IColumn&, DB::ExternalResultDescription::ValueType, int) @ 0x00000000359f9eb2
7. src/Processors/Sources/SQLiteSource.cpp:102: DB::SQLiteSource::generate() @ 0x00000000359f8f1e
8. src/Processors/ISource.cpp:139: DB::ISource::tryGenerate() @ 0x00000000351dd9d4
9. src/Processors/ISource.cpp:108: DB::ISource::work() @ 0x00000000351dcffa
10. src/Processors/Executors/ExecutionThreadContext.cpp:47: DB::ExecutionThreadContext::executeTask() @ 0x000000003520d120
11. src/Processors/Executors/PipelineExecutor.cpp:289: DB::PipelineExecutor::executeStepImpl(unsigned long, std::atomic<bool>*) @ 0x00000000351f7de3
12. src/Processors/Executors/PipelineExecutor.cpp:255: void std::__function::__policy_invoker<void ()>::__call_impl<std::__function::__default_alloc_func<DB::PipelineExecutor::spawnThreads()::$_0, void ()>>(std::__function::__policy_storage const*) @ 0x00000000351f9729
13. ./contrib/llvm-project/libcxx/include/__functional/function.h:848: ? @ 0x00000000255cd37c
14. ./contrib/llvm-project/libcxx/include/__functional/invoke.h:359: ? @ 0x00000000255d5434
15. ./contrib/llvm-project/libcxx/include/__functional/function.h:848: ? @ 0x00000000255caacf
16. ./contrib/llvm-project/libcxx/include/__functional/invoke.h:359: ? @ 0x00000000255d1cca
17. ? @ 0x00007ffff7ca1e2e
18. ? @ 0x00007ffff7d33a4c

Metadata

Metadata

Labels

fuzzProblem found by one of the fuzzerspotential bugTo be reviewed by developers and confirmed/rejected.unexpected behaviourResult is unexpected, but not entirely wrong at the same time.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions