From 6ba8cb922c9799539b92836216199a531c5af1b2 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Mon, 14 May 2018 13:48:50 +0300 Subject: [PATCH] Fix usage of columns from header in SummingSortedBlockInputStream. #2273 --- .../SummingSortedBlockInputStream.cpp | 2 +- .../00625_summing_merge_tree_merge.reference | 0 .../00625_summing_merge_tree_merge.sql | 29 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00625_summing_merge_tree_merge.reference create mode 100644 dbms/tests/queries/0_stateless/00625_summing_merge_tree_merge.sql diff --git a/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp b/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp index e914b8f8b65..62ece4a1545 100644 --- a/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp +++ b/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp @@ -263,7 +263,7 @@ Block SummingSortedBlockInputStream::readImpl() size_t tuple_size = desc.column_numbers.size(); MutableColumns tuple_columns(tuple_size); for (size_t i = 0; i < tuple_size; ++i) - tuple_columns[i] = header.safeGetByPosition(desc.column_numbers[i]).column->assumeMutable(); + tuple_columns[i] = header.safeGetByPosition(desc.column_numbers[i]).column->cloneEmpty(); desc.merged_column = ColumnTuple::create(std::move(tuple_columns)); } diff --git a/dbms/tests/queries/0_stateless/00625_summing_merge_tree_merge.reference b/dbms/tests/queries/0_stateless/00625_summing_merge_tree_merge.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/dbms/tests/queries/0_stateless/00625_summing_merge_tree_merge.sql b/dbms/tests/queries/0_stateless/00625_summing_merge_tree_merge.sql new file mode 100644 index 00000000000..dd629b7bb15 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00625_summing_merge_tree_merge.sql @@ -0,0 +1,29 @@ +DROP TABLE IF EXISTS test.tab ; + +CREATE TABLE test.tab +( + date Date, + key UInt32, + testMap Nested( + k UInt16, + v UInt64) +) +ENGINE = SummingMergeTree(date, (date, key), 1); + +INSERT INTO test.tab SELECT + today(), + number, + [toUInt16(number)], + [number] +FROM system.numbers +LIMIT 8190; + +INSERT INTO test.tab SELECT + today(), + number + 8190, + [toUInt16(number)], + [number + 8190] +FROM system.numbers +LIMIT 10; + +OPTIMIZE TABLE test.tab;