-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Insert is not working for distributed tables with materialized columns #4015
Description
Problem reproduces on inserts into distributed table with such schema:
`CREATE DATABASE shard_1
CREATE TABLE shard_1.test (field_1 UInt8, event_date Date MATERIALIZED today()) ENGINE = MergeTree(event_date, (event_date, field_1), 8192)
CREATE TABLE IF NOT EXISTS test_dist AS shard_1.test ENGINE = Distributed('test_cluster', '','test', cityHash64(event_date))
INSERT INTO default.test_dist (field_1) VALUES(0);`
After that exception of server is falling
`2019.01.09 16:52:58.097140 [ 28 ] {} test_dist.Distributed.DirectoryMonitor: Code: 44, e.displayText() = DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Cannot insert column event_date, because it is MATERIALIZED column.. Stack trace:
- /usr/bin/clickhouse-server(StackTrace::StackTrace()+0x16) [0x9c778f6]
- /usr/bin/clickhouse-server(DB::InterpreterInsertQuery::getSampleBlock(DB::ASTInsertQuery const&, std::shared_ptrDB::IStorage const&)+0xbe0) [0x6ebbc60]
- /usr/bin/clickhouse-server(DB::InterpreterInsertQuery::execute()+0x36a) [0x6ebc2ea]
- /usr/bin/clickhouse-server() [0x6fbe247]
- /usr/bin/clickhouse-server(DB::executeQuery(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum)+0x8a) [0x6fc01da]
- /usr/bin/clickhouse-server(DB::TCPHandler::runImpl()+0x4d5) [0x32c4455]
- /usr/bin/clickhouse-server(DB::TCPHandler::run()+0x2b) [0x32c563b]
- /usr/bin/clickhouse-server(Poco::Net::TCPServerConnection::start()+0xf) [0x9dfb50f]
- /usr/bin/clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0x16a) [0x9dfb8ea]
- /usr/bin/clickhouse-server(Poco::PooledThread::run()+0x77) [0xa0ce957]
- /usr/bin/clickhouse-server(Poco::ThreadImpl::runnableEntry(void*)+0x38) [0xa0ca818]
- /usr/bin/clickhouse-server() [0xa94e40f]
- /lib/x86_64-linux-gnu/libpthread.so.0(+0x76db) [0x7fd7a889d6db]
- /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7fd7a7e1c88f]`
I assume problem is somewhere in generated temporary files for distributed tables *.bin, because in the new version of CH they starts from insert script with all columns(including materialized).
In previous version of CH they weren't including materialized columns. This issue fully blocks all insert into the target of the distributed table.
Problem reproduces in version 18.16.1 (in 18.14.13 everything is ok)