-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57451 from ClickHouse/backport/23.10/56948
Backport #56948 to 23.10: Prevent incompatible ALTER of projection columns
- Loading branch information
Showing
7 changed files
with
127 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tests/queries/0_stateless/02920_alter_column_of_projections.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
1 | ||
1 | ||
1 | ||
1 | ||
1 | ||
1 | ||
1 | ||
1 |
33 changes: 33 additions & 0 deletions
33
tests/queries/0_stateless/02920_alter_column_of_projections.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
DROP TABLE IF EXISTS t; | ||
|
||
CREATE TABLE t (uid Int16, name String, age Nullable(Int8), i Int16, j Int16, projection p1 (select name, age, uniq(i), count(j) group by name, age)) ENGINE=MergeTree order by uid settings index_granularity = 1; | ||
|
||
INSERT INTO t VALUES (1231, 'John', 11, 1, 1), (6666, 'Ksenia', 1, 2, 2), (8888, 'Alice', 1, 3, 3), (6667, 'Ksenia', null, 4, 4); | ||
|
||
-- Cannot ALTER, which breaks key column of projection. | ||
ALTER TABLE t MODIFY COLUMN age Nullable(Int32); -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN } | ||
|
||
-- Cannot ALTER, uniq(Int16) is not compatible with uniq(Int32). | ||
ALTER TABLE t MODIFY COLUMN i Int32; -- { serverError CANNOT_CONVERT_TYPE } | ||
|
||
SYSTEM STOP MERGES t; | ||
|
||
SET alter_sync = 0; | ||
|
||
-- Can ALTER, count(Int16) is compatible with count(Int32). | ||
ALTER TABLE t MODIFY COLUMN j Int32; | ||
|
||
-- Projection query works without mutation applied. | ||
SELECT count(j) FROM t GROUP BY name, age; | ||
|
||
SYSTEM START MERGES t; | ||
|
||
SET alter_sync = 1; | ||
|
||
-- Another ALTER to wait for. | ||
ALTER TABLE t MODIFY COLUMN j Int64 SETTINGS mutations_sync = 2; | ||
|
||
-- Projection query works with mutation applied. | ||
SELECT count(j) FROM t GROUP BY name, age; | ||
|
||
DROP TABLE t; |
Empty file.
31 changes: 31 additions & 0 deletions
31
tests/queries/0_stateless/02920_rename_column_of_skip_indices.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |