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 #51304 from ClickHouse/alter-table-add-comment
Add support for ALTER TABLE MODIFY COMMENT
- Loading branch information
Showing
12 changed files
with
160 additions
and
20 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
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
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
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
20 changes: 20 additions & 0 deletions
20
tests/queries/0_stateless/02792_alter_table_modify_comment.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,20 @@ | ||
Hello | ||
World | ||
Hello | ||
World | ||
Hello | ||
World | ||
Hello | ||
World | ||
Hello | ||
World | ||
|
||
World | ||
|
||
World | ||
|
||
World | ||
|
||
World | ||
|
||
World |
72 changes: 72 additions & 0 deletions
72
tests/queries/0_stateless/02792_alter_table_modify_comment.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,72 @@ | ||
-- Tags: no-replicated-database | ||
-- Tag no-replicated-database: Unsupported type of ALTER query | ||
|
||
DROP TABLE IF EXISTS t; | ||
|
||
# Memory, MergeTree, and ReplicatedMergeTree | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = Memory COMMENT 'Hello'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t; | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = MergeTree ORDER BY () COMMENT 'Hello'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t; | ||
|
||
# The case when there are many operations in one ALTER | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = MergeTree ORDER BY () COMMENT 'Hello'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World', MODIFY COLUMN x UInt16; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t; | ||
|
||
# Note that the table comment is not replicated. We can implement it later. | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_comment_table1/t', '1') ORDER BY () COMMENT 'Hello'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t SYNC; | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_comment_table2/t', '1') ORDER BY () COMMENT 'Hello'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World', MODIFY COLUMN x UInt16; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t SYNC; | ||
|
||
# The cases when there is no comment on creation | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = Memory; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t; | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = MergeTree ORDER BY (); | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t; | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = MergeTree ORDER BY (); | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World', MODIFY COLUMN x UInt16; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t; | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_comment_table3/t', '1') ORDER BY (); | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World'; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t SYNC; | ||
|
||
CREATE TABLE t (x UInt8) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_comment_table4/t', '1') ORDER BY (); | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
ALTER TABLE t MODIFY COMMENT 'World', MODIFY COLUMN x UInt16; | ||
SELECT comment FROM system.tables WHERE database = currentDatabase() AND table = 't'; | ||
DROP TABLE t SYNC; |