forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
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 ClickHouse#55373 from lingtaolf/enhancement/rename…
…_without_keyword Support rename table without keyword TABLE
- Loading branch information
Showing
4 changed files
with
70 additions
and
13 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
7 changes: 7 additions & 0 deletions
7
tests/queries/0_stateless/02891_rename_table_without_keyword.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,7 @@ | ||
r1 | ||
r1_bak | ||
r1 | ||
r1_bak | ||
r2_bak | ||
test_dictionary | ||
test_dictionary_2 |
42 changes: 42 additions & 0 deletions
42
tests/queries/0_stateless/02891_rename_table_without_keyword.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,42 @@ | ||
DROP DATABASE IF EXISTS {CLICKHOUSE_DATABASE:Identifier}; | ||
CREATE DATABASE IF NOT EXISTS {CLICKHOUSE_DATABASE:Identifier}; | ||
|
||
CREATE TABLE IF NOT EXISTS {CLICKHOUSE_DATABASE:Identifier}.r1 (name String) Engine=Memory(); | ||
SHOW TABLES FROM {CLICKHOUSE_DATABASE:Identifier}; | ||
|
||
RENAME TABLE {CLICKHOUSE_DATABASE:Identifier}.r1 TO {CLICKHOUSE_DATABASE:Identifier}.r1_bak; | ||
SHOW TABLES FROM {CLICKHOUSE_DATABASE:Identifier}; | ||
|
||
RENAME {CLICKHOUSE_DATABASE:Identifier}.r1_bak TO {CLICKHOUSE_DATABASE:Identifier}.r1; | ||
SHOW TABLES FROM {CLICKHOUSE_DATABASE:Identifier}; | ||
|
||
CREATE TABLE IF NOT EXISTS {CLICKHOUSE_DATABASE:Identifier}.r2 (name String) Engine=Memory(); | ||
RENAME {CLICKHOUSE_DATABASE:Identifier}.r1 TO {CLICKHOUSE_DATABASE:Identifier}.r1_bak, | ||
{CLICKHOUSE_DATABASE:Identifier}.r2 TO {CLICKHOUSE_DATABASE:Identifier}.r2_bak; | ||
SHOW TABLES FROM {CLICKHOUSE_DATABASE:Identifier}; | ||
|
||
CREATE TABLE IF NOT EXISTS {CLICKHOUSE_DATABASE:Identifier}.source_table ( | ||
id UInt64, | ||
value String | ||
) ENGINE = Memory; | ||
|
||
CREATE DICTIONARY IF NOT EXISTS {CLICKHOUSE_DATABASE:Identifier}.test_dictionary | ||
( | ||
id UInt64, | ||
value String | ||
) | ||
PRIMARY KEY id | ||
SOURCE(CLICKHOUSE(TABLE '{CLICKHOUSE_DATABASE:String}.dictionary_table')) | ||
LAYOUT(FLAT()) | ||
LIFETIME(MIN 0 MAX 1000); | ||
|
||
SHOW DICTIONARIES FROM {CLICKHOUSE_DATABASE:Identifier}; | ||
|
||
RENAME {CLICKHOUSE_DATABASE:Identifier}.test_dictionary TO {CLICKHOUSE_DATABASE:Identifier}.test_dictionary_2; | ||
SHOW DICTIONARIES FROM {CLICKHOUSE_DATABASE:Identifier}; | ||
|
||
SHOW DATABASES LIKE '{CLICKHOUSE_DATABASE:String}'; | ||
RENAME {CLICKHOUSE_DATABASE:Identifier} TO {CLICKHOUSE_DATABASE_1:Identifier}; -- { serverError UNKNOWN_TABLE } | ||
SHOW DATABASES LIKE '{CLICKHOUSE_DATABASE:String}'; | ||
|
||
DROP DATABASE IF EXISTS {CLICKHOUSE_DATABASE:Identifier}; |