mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fix detach/attach for ReplicatedVersionedCollapsingMergeTree after alter
This commit is contained in:
parent
ab3e005e6a
commit
ba78a737dc
@ -46,7 +46,15 @@ ReplicatedMergeTreeTableMetadata::ReplicatedMergeTreeTableMetadata(const MergeTr
|
||||
|
||||
primary_key = formattedAST(metadata_snapshot->getPrimaryKey().expression_list_ast);
|
||||
if (metadata_snapshot->isPrimaryKeyDefined())
|
||||
sorting_key = formattedAST(metadata_snapshot->getSortingKey().expression_list_ast);
|
||||
{
|
||||
/// We don't use preparsed AST `sorting_key.expression_list_ast` because
|
||||
/// it contain version column for VersionedCollapsingMergeTree, which
|
||||
/// shouldn't be defined as a part of key definition AST. So the best
|
||||
/// compatible way is just to convert definition_ast to list and
|
||||
/// serialize it. In all other places key.expression_list_ast should be
|
||||
/// used.
|
||||
sorting_key = formattedAST(extractKeyExpressionList(metadata_snapshot->getSortingKey().definition_ast));
|
||||
}
|
||||
|
||||
data_format_version = data.format_version;
|
||||
|
||||
|
@ -19,10 +19,20 @@ SETTINGS index_granularity = 8192;
|
||||
|
||||
INSERT INTO table_for_alter VALUES(toDate('2019-10-01'), 'a', 1, 'aa', 1, 1, 1);
|
||||
|
||||
DETACH TABLE table_for_alter;
|
||||
|
||||
ATTACH TABLE table_for_alter;
|
||||
|
||||
|
||||
SELECT * FROM table_for_alter;
|
||||
|
||||
ALTER TABLE table_for_alter ADD COLUMN order UInt32, MODIFY ORDER BY (d, order);
|
||||
|
||||
|
||||
DETACH TABLE table_for_alter;
|
||||
|
||||
ATTACH TABLE table_for_alter;
|
||||
|
||||
SELECT * FROM table_for_alter;
|
||||
|
||||
SHOW CREATE TABLE table_for_alter;
|
||||
@ -35,4 +45,8 @@ SELECT * FROM table_for_alter ORDER BY d;
|
||||
|
||||
SHOW CREATE TABLE table_for_alter;
|
||||
|
||||
DETACH TABLE table_for_alter;
|
||||
|
||||
ATTACH TABLE table_for_alter;
|
||||
|
||||
DROP TABLE IF EXISTS table_for_alter;
|
||||
|
Loading…
Reference in New Issue
Block a user