mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 18:42:26 +00:00
Allow RENAME of index columns.
This commit is contained in:
parent
6581aaf9e8
commit
ee1cec4d38
@ -3047,8 +3047,7 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, Context
|
||||
backQuoteIfNeed(command.column_name));
|
||||
}
|
||||
|
||||
/// Don't check columns in indices here. If required columns of indices get renamed, it
|
||||
/// will be checked later in AlterCommands::apply.
|
||||
/// Don't check columns in indices here. RENAME works fine with index columns.
|
||||
|
||||
if (auto it = columns_in_projections.find(command.column_name); it != columns_in_projections.end())
|
||||
{
|
||||
|
@ -52,6 +52,4 @@ ALTER TABLE table_for_rename_with_primary_key RENAME COLUMN key2 TO renamed_key2
|
||||
|
||||
ALTER TABLE table_for_rename_with_primary_key RENAME COLUMN key3 TO renamed_key3; --{serverError 524}
|
||||
|
||||
ALTER TABLE table_for_rename_with_primary_key RENAME COLUMN value1 TO renamed_value1; --{serverError 524}
|
||||
|
||||
DROP TABLE IF EXISTS table_for_rename_with_primary_key;
|
||||
|
@ -0,0 +1,31 @@
|
||||
DROP TABLE IF EXISTS t;
|
||||
|
||||
CREATE TABLE t
|
||||
(
|
||||
key1 UInt64,
|
||||
value1 String,
|
||||
value2 String,
|
||||
INDEX idx (value1) TYPE set(10) GRANULARITY 1
|
||||
)
|
||||
ENGINE MergeTree ORDER BY key1 SETTINGS index_granularity = 1;
|
||||
|
||||
INSERT INTO t SELECT toDate('2019-10-01') + number % 3, toString(number), toString(number) from numbers(9);
|
||||
|
||||
SYSTEM STOP MERGES t;
|
||||
|
||||
SET alter_sync = 0;
|
||||
|
||||
ALTER TABLE t RENAME COLUMN value1 TO value11;
|
||||
|
||||
-- Index works without mutation applied.
|
||||
SELECT * FROM t WHERE value11 = '000' SETTINGS max_rows_to_read = 0;
|
||||
|
||||
SYSTEM START MERGES t;
|
||||
|
||||
-- Another ALTER to wait for.
|
||||
ALTER TABLE t RENAME COLUMN value11 TO value12 SETTINGS mutations_sync = 2;
|
||||
|
||||
-- Index works with mutation applied.
|
||||
SELECT * FROM t WHERE value12 = '000' SETTINGS max_rows_to_read = 0;
|
||||
|
||||
DROP TABLE t;
|
Loading…
Reference in New Issue
Block a user