forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent incompatible ALTER of projection columns.
- Loading branch information
Showing
4 changed files
with
95 additions
and
7 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
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; |