fix mutations

This commit is contained in:
CurtizJ 2020-01-20 21:58:56 +03:00
parent b0906abb0d
commit d0731878c9
4 changed files with 94 additions and 3 deletions

View File

@ -32,6 +32,4 @@ Block IMergedBlockOutputStream::getBlockAndPermute(const Block & block, const Na
return result;
}
/// Implementation of IMergedBlockOutputStream::ColumnStream.
}

View File

@ -1021,7 +1021,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
MergeStageProgress stage_progress(1.0);
in->setProgressCallback(MergeProgressCallback(merge_entry, watch_prev_elapsed, stage_progress));
if (updated_header.columns() == all_columns.size())
if (source_part->getColumns().isSubsetOf(updated_header.getNamesAndTypesList()))
{
/// All columns are modified, proceed to write a new part from scratch.
if (data.hasPrimaryKey() || data.hasSkipIndices())

View File

@ -0,0 +1,47 @@
0 0 1167657 [0,0,0] ['a','b','c'] baz
1 1 2072334 [0,0,0] ['a','b','c'] bar
2 4 843568 [0,0,0] ['a','b','c'] baz
3 9 1748245 [0,0,0] ['a','b','c'] bar
4 16 519479 [0,0,0] ['a','b','c'] baz
5 25 1424156 [0,0,0] ['a','b','c'] bar
6 36 195390 [0,0,0] ['a','b','c'] baz
7 49 1100067 [0,0,0] ['a','b','c'] bar
8 64 2004744 [0,0,0] ['a','b','c'] baz
9 81 775978 [0,0,0] ['a','b','c'] bar
=====================
Compact
Compact 7
Wide 3
0 0 1167657 [1,2] ['',''] 0
0 0 1167657 [0,0,0] ['a','b','c'] baz
0 0 1748245 [1,2] ['',''] 3
1 1 2072334 [1,2] ['',''] 1
1 1 2072334 [0,0,0] ['a','b','c'] bar
1 1 519479 [1,2] ['',''] 4
2 4 843568 [0,0,0] ['a','b','c'] baz
2 4 843568 [1,2] ['',''] 2
3 9 1748245 [0,0,0] ['a','b','c'] bar
4 16 519479 [0,0,0] ['a','b','c'] baz
=====================
0 0 1167657 [1,2] ['qwqw'] 0
0 0 1167657 [0,0,0] ['qwqw'] baz
0 0 1748245 [1,2] ['qwqw'] 3
1 1 2072334 [1,2] ['qwqw'] 1
1 1 2072334 [0,0,0] ['qwqw'] bar
1 1 519479 [1,2] ['qwqw'] 4
2 4 843568 [0,0,0] ['qwqw'] baz
2 4 843568 [1,2] ['qwqw'] 2
3 9 1748245 [0,0,0] ['qwqw'] bar
4 16 519479 [0,0,0] ['qwqw'] baz
=====================
2 42 843568 [1,2] ['qwqw'] 2
2 42 843568 [0,0,0] ['qwqw'] baz
3 42 1748245 [0,0,0] ['qwqw'] bar
4 42 519479 [0,0,0] ['qwqw'] baz
5 42 1424156 [0,0,0] ['qwqw'] bar
6 42 195390 [0,0,0] ['qwqw'] baz
7 42 1100067 [0,0,0] ['qwqw'] bar
8 42 2004744 [0,0,0] ['qwqw'] baz
9 42 775978 [0,0,0] ['qwqw'] bar
10 42 1680655 [0,0,0] ['qwqw'] baz
=====================

View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
. $CURDIR/mergetree_mutations.lib
# Testing basic functionality with compact parts
${CLICKHOUSE_CLIENT} --query="drop table if exists mt_compact;"
${CLICKHOUSE_CLIENT} --query="create table mt_compact(a UInt64, b UInt64 DEFAULT a * a, s String, n Nested(x UInt32, y String), lc LowCardinality(String)) \
engine = MergeTree \
order by a partition by a % 10 \
settings index_granularity = 8, \
min_rows_for_wide_part = 10;"
${CLICKHOUSE_CLIENT} --query="insert into mt_compact (a, s, n.y, lc) select number, toString((number * 2132214234 + 5434543) % 2133443), ['a', 'b', 'c'], number % 2 ? 'bar' : 'baz' from numbers(90);"
${CLICKHOUSE_CLIENT} --query="select * from mt_compact order by a limit 10;"
${CLICKHOUSE_CLIENT} --query="select '=====================';"
${CLICKHOUSE_CLIENT} --query="select distinct part_type from system.parts where database = currentDatabase() and table = 'mt_compact' and active;"
${CLICKHOUSE_CLIENT} --query="insert into mt_compact (a, s, n.x, lc) select number % 3, toString((number * 2132214234 + 5434543) % 2133443), [1, 2], toString(number) from numbers(5);"
${CLICKHOUSE_CLIENT} --query="optimize table mt_compact final;"
${CLICKHOUSE_CLIENT} --query="select part_type, count() from system.parts where database = currentDatabase() and table = 'mt_compact' and active group by part_type; "
${CLICKHOUSE_CLIENT} --query="select * from mt_compact order by a, s limit 10;"
${CLICKHOUSE_CLIENT} --query="select '=====================';"
${CLICKHOUSE_CLIENT} --query="alter table mt_compact drop column n.y;"
${CLICKHOUSE_CLIENT} --query="alter table mt_compact add column n.y Array(String) DEFAULT ['qwqw'] after n.x;"
${CLICKHOUSE_CLIENT} --query="select * from mt_compact order by a, s limit 10;"
${CLICKHOUSE_CLIENT} --query="select '=====================';"
${CLICKHOUSE_CLIENT} --query="alter table mt_compact update b = 42 where 1;"
sleep 0.5
mutation_id=`${CLICKHOUSE_CLIENT} --query="SELECT max(mutation_id) FROM system.mutations WHERE table='mt_compact'"`
wait_for_mutation "mt_compact" "$mutation_id"
${CLICKHOUSE_CLIENT} --query="select * from mt_compact where a > 1 order by a, s limit 10;"
${CLICKHOUSE_CLIENT} --query="select '=====================';"
${CLICKHOUSE_CLIENT} --query="drop table if exists mt_compact;"