Skip to content

Insert is not working for distributed tables with materialized columns #4015

@lapkofear

Description

@lapkofear

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:

  1. /usr/bin/clickhouse-server(StackTrace::StackTrace()+0x16) [0x9c778f6]
  2. /usr/bin/clickhouse-server(DB::InterpreterInsertQuery::getSampleBlock(DB::ASTInsertQuery const&, std::shared_ptrDB::IStorage const&)+0xbe0) [0x6ebbc60]
  3. /usr/bin/clickhouse-server(DB::InterpreterInsertQuery::execute()+0x36a) [0x6ebc2ea]
  4. /usr/bin/clickhouse-server() [0x6fbe247]
  5. /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]
  6. /usr/bin/clickhouse-server(DB::TCPHandler::runImpl()+0x4d5) [0x32c4455]
  7. /usr/bin/clickhouse-server(DB::TCPHandler::run()+0x2b) [0x32c563b]
  8. /usr/bin/clickhouse-server(Poco::Net::TCPServerConnection::start()+0xf) [0x9dfb50f]
  9. /usr/bin/clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0x16a) [0x9dfb8ea]
  10. /usr/bin/clickhouse-server(Poco::PooledThread::run()+0x77) [0xa0ce957]
  11. /usr/bin/clickhouse-server(Poco::ThreadImpl::runnableEntry(void*)+0x38) [0xa0ca818]
  12. /usr/bin/clickhouse-server() [0xa94e40f]
  13. /lib/x86_64-linux-gnu/libpthread.so.0(+0x76db) [0x7fd7a889d6db]
  14. /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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed user-visible misbehaviour in official release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions