From a9b675297ed7b8f1c7832f634087abdb74a93c51 Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 30 Mar 2020 17:40:43 +0300 Subject: [PATCH] Better --- .../Storages/MergeTree/MergeTreeDataMergerMutator.cpp | 2 -- .../0_stateless/01213_alter_rename_column.reference | 3 +++ .../queries/0_stateless/01213_alter_rename_column.sql | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp index 00637dc5017..894f05d6aca 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp @@ -1114,9 +1114,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor for (const auto & [rename_from, rename_to] : files_to_rename) { if (rename_to.empty() && new_data_part->checksums.files.count(rename_from)) - { new_data_part->checksums.files.erase(rename_from); - } else if (new_data_part->checksums.files.count(rename_from)) { new_data_part->checksums.files[rename_to] = new_data_part->checksums.files[rename_from]; diff --git a/dbms/tests/queries/0_stateless/01213_alter_rename_column.reference b/dbms/tests/queries/0_stateless/01213_alter_rename_column.reference index 8595d2f423a..a5e642f56ad 100644 --- a/dbms/tests/queries/0_stateless/01213_alter_rename_column.reference +++ b/dbms/tests/queries/0_stateless/01213_alter_rename_column.reference @@ -2,3 +2,6 @@ 1 date key renamed_value1 value2 value3 2019-10-02 1 1 1 1 +7 7 +date key renamed_value1 renamed_value2 renamed_value3 +2019-10-02 7 7 7 7 diff --git a/dbms/tests/queries/0_stateless/01213_alter_rename_column.sql b/dbms/tests/queries/0_stateless/01213_alter_rename_column.sql index 8599360cdeb..7c6209ac0b4 100644 --- a/dbms/tests/queries/0_stateless/01213_alter_rename_column.sql +++ b/dbms/tests/queries/0_stateless/01213_alter_rename_column.sql @@ -24,6 +24,13 @@ SELECT * FROM table_for_rename WHERE key = 1 FORMAT TSVWithNames; ALTER TABLE table_for_rename RENAME COLUMN value3 to value2; --{serverError 15} ALTER TABLE table_for_rename RENAME COLUMN value3 TO r1, RENAME COLUMN value3 TO r2; --{serverError 36} -ALTER TABLE table_for_rename RENAME COLUMN value3 TO r1, RENAME COLUMN r1 TO value1; --{serverError 36} +ALTER TABLE table_for_rename RENAME COLUMN value3 TO r1, RENAME COLUMN r1 TO value1; --{serverError 10} + + +ALTER TABLE table_for_rename RENAME COLUMN value2 TO renamed_value2, RENAME COLUMN value3 TO renamed_value3; + +SELECT renamed_value2, renamed_value3 FROM table_for_rename WHERE key = 7; + +SELECT * FROM table_for_rename WHERE key = 7 FORMAT TSVWithNames; DROP TABLE IF EXISTS table_for_rename;