Merge branch 'master' of github.com:yandex/ClickHouse

This commit is contained in:
Alexey Milovidov 2020-01-31 23:24:30 +03:00
commit 9701b006af
10 changed files with 42 additions and 28 deletions

View File

@ -156,7 +156,7 @@ SummingSortedBlockInputStream::SummingSortedBlockInputStream(
|| endsWith(name, "Key")
|| endsWith(name, "Type"))
{
if (!nested_type.isValueRepresentedByInteger())
if (!nested_type.isValueRepresentedByInteger() && !isStringOrFixedString(nested_type))
break;
map_desc.key_col_nums.push_back(*column_num_it);

View File

@ -1272,8 +1272,8 @@ MarkRanges MergeTreeDataSelectExecutor::filterMarksUsingIndex(
const size_t min_marks_for_seek = roundRowsOrBytesToMarks(
settings.merge_tree_min_rows_for_seek,
settings.merge_tree_min_bytes_for_seek,
part->index_granularity_info.index_granularity_bytes,
part->index_granularity_info.fixed_index_granularity);
part->index_granularity_info.fixed_index_granularity,
part->index_granularity_info.index_granularity_bytes);
size_t granules_dropped = 0;

View File

@ -399,7 +399,7 @@ BlockInputStreams StorageDistributed::read(
if (force)
{
std::stringstream exception_message;
if (has_sharding_key)
if (!has_sharding_key)
exception_message << "No sharding key";
else
exception_message << "Sharding key " << sharding_key_column_name << " is not used";

View File

@ -2,6 +2,10 @@
[1] [250]
[1,2] [250,150]
[2] [150]
['1','2'] [100,150]
['1'] [250]
['1','2'] [250,150]
['2'] [150]
20 [1,2] [100,150]
20 [1] [250]
20 [1,2] [250,150]

View File

@ -9,6 +9,15 @@ select `SomeMap.ID`, `SomeMap.Num` from nested_map;
drop table nested_map;
create table nested_map (d default today(), k UInt64, payload default rand(), SomeMap Nested(ID String, Num Int64)) engine=SummingMergeTree(d, k, 8192);
insert into nested_map (k, `SomeMap.ID`, `SomeMap.Num`) values (0,['1'],[100]),(1,['1'],[100]),(2,['1'],[100]),(3,['1','2'],[100,150]);
insert into nested_map (k, `SomeMap.ID`, `SomeMap.Num`) values (0,['2'],[150]),(1,['1'],[150]),(2,['1','2'],[150,150]),(3,['1'],[-100]);
optimize table nested_map;
select `SomeMap.ID`, `SomeMap.Num` from nested_map;
drop table nested_map;
drop table if exists nested_map_explicit;
create table nested_map_explicit (d default today(), k UInt64, SomeIntExcluded UInt32, SomeMap Nested(ID UInt32, Num Int64)) engine=SummingMergeTree(d, k, 8192, (SomeMap));

View File

@ -1,8 +1,8 @@
2000-01-01 1 [1,2] [3,4] [10,11] [0,1,2] [3,4,5] [-1,-2,-3] [1,10,100]
2000-01-01 1 [2,1] [4,3] [20,22] [2,2,1] [5,5,0] [-3,-3,-33] [10,100,1000]
2000-01-01 2 [1,2] [3,4] [10,11] [0,1,2] [3,4,5] [-1,-2,-3] [1,10,100]
2000-01-01 2 [2,1,1] [4,3,3] [20,22,33] [2,2] [5,5] [-3,-3] [10,100]
2000-01-01 2 [1,2] [3,4] [10,11] [0,1,2] [3,4,5] [-1,-2,-3] [1,10,100]
2000-01-01 1 [1,2] [3,4] [10,11] [0,1,2] ['3','4','5'] [-1,-2,-3] [1,10,100]
2000-01-01 1 [2,1] [4,3] [20,22] [2,2,1] ['5','5','0'] [-3,-3,-33] [10,100,1000]
2000-01-01 2 [1,2] [3,4] [10,11] [0,1,2] ['3','4','5'] [-1,-2,-3] [1,10,100]
2000-01-01 2 [2,1,1] [4,3,3] [20,22,33] [2,2] ['5','5'] [-3,-3] [10,100]
2000-01-01 2 [1,2] [3,4] [10,11] [0,1,2] ['3','4','5'] [-1,-2,-3] [1,10,100]
2000-01-01 1 1 3 10
2000-01-01 1 1 3 22
2000-01-01 1 2 4 11
@ -50,8 +50,8 @@
2000-01-01 2 0 3 -1 2
2000-01-01 2 1 4 -2 20
2000-01-01 2 2 5 -3 310
2000-01-01 1 [1,2] [3,4] [32,31] [0,1,1,2] [3,0,4,5] [-1,-33,-2,-3] [1,1000,10,210]
2000-01-01 2 [1,2] [3,4] [75,42] [0,1,2] [3,4,5] [-1,-2,-3] [2,20,310]
2000-01-01 1 [1,2] [3,4] [32,31] [0,1,1,2] ['3','0','4','5'] [-1,-33,-2,-3] [1,1000,10,210]
2000-01-01 2 [1,2] [3,4] [75,42] [0,1,2] ['3','4','5'] [-1,-2,-3] [2,20,310]
2000-01-01 1 1 3 32
2000-01-01 1 2 4 31
2000-01-01 2 1 3 75

View File

@ -1,7 +1,7 @@
DROP TABLE IF EXISTS summing_composite_key;
CREATE TABLE summing_composite_key (d Date, k UInt64, FirstMap Nested(k1 UInt32, k2ID Int8, s Float64), SecondMap Nested(k1ID UInt64, k2Key UInt32, k3Type Int32, s Int64)) ENGINE = SummingMergeTree(d, k, 1);
CREATE TABLE summing_composite_key (d Date, k UInt64, FirstMap Nested(k1 UInt32, k2ID Int8, s Float64), SecondMap Nested(k1ID UInt64, k2Key String, k3Type Int32, s Int64)) ENGINE = SummingMergeTree(d, k, 1);
INSERT INTO summing_composite_key VALUES ('2000-01-01', 1, [1,2], [3,4], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]), ('2000-01-01', 1, [2,1], [4,3], [20,22], [2,2,1], [5,5,0], [-3,-3,-33], [10,100,1000]), ('2000-01-01', 2, [1,2], [3,4], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]), ('2000-01-01', 2, [2,1,1], [4,3,3], [20,22,33], [2,2], [5,5], [-3,-3], [10,100]), ('2000-01-01', 2, [1,2], [3,4], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]);
INSERT INTO summing_composite_key VALUES ('2000-01-01', 1, [1,2], ['3','4'], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]), ('2000-01-01', 1, [2,1], ['4','3'], [20,22], [2,2,1], [5,5,0], [-3,-3,-33], [10,100,1000]), ('2000-01-01', 2, [1,2], ['3','4'], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]), ('2000-01-01', 2, [2,1,1], ['4','3','3'], [20,22,33], [2,2], [5,5], [-3,-3], [10,100]), ('2000-01-01', 2, [1,2], ['3','4'], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]);
SELECT * FROM summing_composite_key ORDER BY d, k, _part_index;

View File

@ -1,26 +1,26 @@
set optimize_skip_unused_shards=1;
drop table if exists data_01068;
drop table if exists dist_01068;
drop table if exists data_01071;
drop table if exists dist_01071;
create table data_01068 (key Int) Engine=Null();
create table data_01071 (key Int) Engine=Null();
create table dist_01068 as data_01068 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01068);
create table dist_01071 as data_01071 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01071);
set force_optimize_skip_unused_shards=0;
select * from dist_01068;
select * from dist_01071;
set force_optimize_skip_unused_shards=1;
select * from dist_01068;
select * from dist_01071;
set force_optimize_skip_unused_shards=2;
select * from dist_01068; -- { serverError 507 }
select * from dist_01071; -- { serverError 507 }
drop table if exists dist_01068;
create table dist_01068 as data_01068 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01068, key%2);
drop table if exists dist_01071;
create table dist_01071 as data_01071 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01071, key%2);
set force_optimize_skip_unused_shards=0;
select * from dist_01068;
select * from dist_01071;
set force_optimize_skip_unused_shards=1;
select * from dist_01068; -- { serverError 507 }
select * from dist_01071; -- { serverError 507 }
set force_optimize_skip_unused_shards=2;
select * from dist_01068; -- { serverError 507 }
select * from dist_01071; -- { serverError 507 }
drop table if exists data_01068;
drop table if exists dist_01068;
drop table if exists data_01071;
drop table if exists dist_01071;

View File

@ -112,7 +112,7 @@ Table can have nested data structures that are processed in a special way.
If the name of a nested table ends with `Map` and it contains at least two columns that meet the following criteria:
- the first column is numeric `(*Int*, Date, DateTime)`, let's call it `key`,
- the first column is numeric `(*Int*, Date, DateTime)` or a string `(String, FixedString)`, let's call it `key`,
- the other columns are arithmetic `(*Int*, Float32/64)`, let's call it `(values...)`,
then this nested table is interpreted as a mapping of `key => (values...)`, and when merging its rows, the elements of two data sets are merged by `key` with a summation of the corresponding `(values...)`.

View File

@ -12,6 +12,7 @@ Disallow: /docs/ru/search.html
Disallow: /docs/ja/search.html
Disallow: /docs/zh/search.html
Disallow: /docs/fa/search.html
Disallow: /cdn-cgi/
Allow: /
Host: https://clickhouse.tech
Sitemap: https://clickhouse.tech/docs/sitemap.xml