Adding more tests to check renaming of columns.

This commit is contained in:
Vitaliy Zakaznikov 2020-05-11 19:01:06 +02:00
parent 089371ddfb
commit 9780da3e74
6 changed files with 291 additions and 0 deletions

View File

@ -0,0 +1,87 @@
2019-10-01 0 0 1 0 + 1
2019-10-02 1 1 2 1 + 2
2019-10-03 2 2 3 2 + 3
2019-10-01 3 3 4 3 + 4
2019-10-02 4 4 5 4 + 5
2019-10-03 5 5 6 5 + 6
2019-10-01 6 6 7 6 + 7
2019-10-02 7 7 8 7 + 8
2019-10-03 8 8 9 8 + 9
CREATE TABLE default.table_for_rename\n(\n `date` Date, \n `key` UInt64, \n `value4` String, \n `value5` String, \n `value3` String DEFAULT concat(value4, \' + \', value5)\n)\nENGINE = MergeTree()\nPARTITION BY date\nORDER BY key\nSETTINGS index_granularity = 8192
2019-10-01 0 0 1 0 + 1
2019-10-02 1 1 2 1 + 2
2019-10-03 2 2 3 2 + 3
2019-10-01 3 3 4 3 + 4
2019-10-02 4 4 5 4 + 5
2019-10-03 5 5 6 5 + 6
2019-10-01 6 6 7 6 + 7
2019-10-02 7 7 8 7 + 8
2019-10-03 8 8 9 8 + 9
2019-10-01 0 0 1 0 + 1
2019-10-02 1 1 2 1 + 2
2019-10-03 2 2 3 2 + 3
2019-10-01 3 3 4 3 + 4
2019-10-02 4 4 5 4 + 5
2019-10-03 5 5 6 5 + 6
2019-10-01 6 6 7 6 + 7
2019-10-02 7 7 8 7 + 8
2019-10-03 8 8 9 8 + 9
2019-10-02 10 10 11 10 + 11
2019-10-03 11 11 12 11 + 12
2019-10-01 12 12 13 12 + 13
2019-10-02 13 13 14 13 + 14
2019-10-03 14 14 15 14 + 15
2019-10-01 15 15 16 15 + 16
2019-10-02 16 16 17 16 + 17
2019-10-03 17 17 18 17 + 18
2019-10-01 18 18 19 18 + 19
2019-10-02 19 19 20 19 + 20
CREATE TABLE default.table_for_rename\n(\n `date` Date, \n `key` UInt64, \n `value1` String, \n `value2` String, \n `value3` String DEFAULT concat(value1, \' + \', value2)\n)\nENGINE = MergeTree()\nPARTITION BY date\nORDER BY key\nSETTINGS index_granularity = 8192
2019-10-01 0 0 1 0 + 1
2019-10-02 1 1 2 1 + 2
2019-10-03 2 2 3 2 + 3
2019-10-01 3 3 4 3 + 4
2019-10-02 4 4 5 4 + 5
2019-10-03 5 5 6 5 + 6
2019-10-01 6 6 7 6 + 7
2019-10-02 7 7 8 7 + 8
2019-10-03 8 8 9 8 + 9
2019-10-02 10 10 11 10 + 11
2019-10-03 11 11 12 11 + 12
2019-10-01 12 12 13 12 + 13
2019-10-02 13 13 14 13 + 14
2019-10-03 14 14 15 14 + 15
2019-10-01 15 15 16 15 + 16
2019-10-02 16 16 17 16 + 17
2019-10-03 17 17 18 17 + 18
2019-10-01 18 18 19 18 + 19
2019-10-02 19 19 20 19 + 20
2019-10-01 0 0 1 0 + 1
2019-10-02 1 1 2 1 + 2
2019-10-03 2 2 3 2 + 3
2019-10-01 3 3 4 3 + 4
2019-10-02 4 4 5 4 + 5
2019-10-03 5 5 6 5 + 6
2019-10-01 6 6 7 6 + 7
2019-10-02 7 7 8 7 + 8
2019-10-03 8 8 9 8 + 9
2019-10-02 10 10 11 10 + 11
2019-10-03 11 11 12 11 + 12
2019-10-01 12 12 13 12 + 13
2019-10-02 13 13 14 13 + 14
2019-10-03 14 14 15 14 + 15
2019-10-01 15 15 16 15 + 16
2019-10-02 16 16 17 16 + 17
2019-10-03 17 17 18 17 + 18
2019-10-01 18 18 19 18 + 19
2019-10-02 19 19 20 19 + 20
2019-10-03 20 20 21 20 + 21
2019-10-01 21 21 22 21 + 22
2019-10-02 22 22 23 22 + 23
2019-10-03 23 23 24 23 + 24
2019-10-01 24 24 25 24 + 25
2019-10-02 25 25 26 25 + 26
2019-10-03 26 26 27 26 + 27
2019-10-01 27 27 28 27 + 28
2019-10-02 28 28 29 28 + 29
2019-10-03 29 29 30 29 + 30

View File

@ -0,0 +1,34 @@
DROP TABLE IF EXISTS table_for_rename;
CREATE TABLE table_for_rename
(
date Date,
key UInt64,
value1 String,
value2 String,
value3 String DEFAULT concat(value1, ' + ', value2)
)
ENGINE = MergeTree()
PARTITION BY date
ORDER BY key;
INSERT INTO table_for_rename (date, key, value1, value2) SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1) from numbers(9);
SELECT * FROM table_for_rename ORDER BY key;
ALTER TABLE table_for_rename RENAME COLUMN value1 TO value4;
ALTER TABLE table_for_rename RENAME COLUMN value2 TO value5;
SHOW CREATE TABLE table_for_rename;
SELECT * FROM table_for_rename ORDER BY key;
INSERT INTO table_for_rename (date, key, value4, value5) SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1) from numbers(10, 10);
SELECT * FROM table_for_rename ORDER BY key;
ALTER TABLE table_for_rename RENAME COLUMN value4 TO value1;
ALTER TABLE table_for_rename RENAME COLUMN value5 TO value2;
SHOW CREATE TABLE table_for_rename;
SELECT * FROM table_for_rename ORDER BY key;
INSERT INTO table_for_rename (date, key, value1, value2) SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1) from numbers(20,10);
SELECT * FROM table_for_rename ORDER BY key;
DROP TABLE IF EXISTS table_for_rename;

View File

@ -0,0 +1,90 @@
2019-10-01 0 0 1
2019-10-02 1 1 2
2019-10-03 2 2 3
2019-10-01 3 3 4
2019-10-02 4 4 5
2019-10-03 5 5 6
2019-10-01 6 6 7
2019-10-02 7 7 8
2019-10-03 8 8 9
CREATE TABLE default.table_for_rename\n(\n `date` Date, \n `key` UInt64, \n `value4` String, \n `value5` String, \n `value3` String MATERIALIZED concat(value4, \' + \', value5)\n)\nENGINE = MergeTree()\nPARTITION BY date\nORDER BY key\nSETTINGS index_granularity = 8192
2019-10-01 0 0 1
2019-10-02 1 1 2
2019-10-03 2 2 3
2019-10-01 3 3 4
2019-10-02 4 4 5
2019-10-03 5 5 6
2019-10-01 6 6 7
2019-10-02 7 7 8
2019-10-03 8 8 9
-- insert after rename --
2019-10-01 0 0 1
2019-10-02 1 1 2
2019-10-03 2 2 3
2019-10-01 3 3 4
2019-10-02 4 4 5
2019-10-03 5 5 6
2019-10-01 6 6 7
2019-10-02 7 7 8
2019-10-03 8 8 9
2019-10-02 10 10 11
2019-10-03 11 11 12
2019-10-01 12 12 13
2019-10-02 13 13 14
2019-10-03 14 14 15
2019-10-01 15 15 16
2019-10-02 16 16 17
2019-10-03 17 17 18
2019-10-01 18 18 19
2019-10-02 19 19 20
-- rename columns back --
CREATE TABLE default.table_for_rename\n(\n `date` Date, \n `key` UInt64, \n `value1` String, \n `value2` String, \n `value3` String MATERIALIZED concat(value1, \' + \', value2)\n)\nENGINE = MergeTree()\nPARTITION BY date\nORDER BY key\nSETTINGS index_granularity = 8192
2019-10-01 0 0 1
2019-10-02 1 1 2
2019-10-03 2 2 3
2019-10-01 3 3 4
2019-10-02 4 4 5
2019-10-03 5 5 6
2019-10-01 6 6 7
2019-10-02 7 7 8
2019-10-03 8 8 9
2019-10-02 10 10 11
2019-10-03 11 11 12
2019-10-01 12 12 13
2019-10-02 13 13 14
2019-10-03 14 14 15
2019-10-01 15 15 16
2019-10-02 16 16 17
2019-10-03 17 17 18
2019-10-01 18 18 19
2019-10-02 19 19 20
-- insert after rename column --
2019-10-01 0 0 1
2019-10-02 1 1 2
2019-10-03 2 2 3
2019-10-01 3 3 4
2019-10-02 4 4 5
2019-10-03 5 5 6
2019-10-01 6 6 7
2019-10-02 7 7 8
2019-10-03 8 8 9
2019-10-02 10 10 11
2019-10-03 11 11 12
2019-10-01 12 12 13
2019-10-02 13 13 14
2019-10-03 14 14 15
2019-10-01 15 15 16
2019-10-02 16 16 17
2019-10-03 17 17 18
2019-10-01 18 18 19
2019-10-02 19 19 20
2019-10-03 20 20 21
2019-10-01 21 21 22
2019-10-02 22 22 23
2019-10-03 23 23 24
2019-10-01 24 24 25
2019-10-02 25 25 26
2019-10-03 26 26 27
2019-10-01 27 27 28
2019-10-02 28 28 29
2019-10-03 29 29 30

View File

@ -0,0 +1,37 @@
DROP TABLE IF EXISTS table_for_rename;
CREATE TABLE table_for_rename
(
date Date,
key UInt64,
value1 String,
value2 String,
value3 String MATERIALIZED concat(value1, ' + ', value2)
)
ENGINE = MergeTree()
PARTITION BY date
ORDER BY key;
INSERT INTO table_for_rename (date, key, value1, value2) SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1) from numbers(9);
SELECT * FROM table_for_rename ORDER BY key;
ALTER TABLE table_for_rename RENAME COLUMN value1 TO value4;
ALTER TABLE table_for_rename RENAME COLUMN value2 TO value5;
SHOW CREATE TABLE table_for_rename;
SELECT * FROM table_for_rename ORDER BY key;
SELECT '-- insert after rename --';
INSERT INTO table_for_rename (date, key, value4, value5) SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1) from numbers(10, 10);
SELECT * FROM table_for_rename ORDER BY key;
SELECT '-- rename columns back --';
ALTER TABLE table_for_rename RENAME COLUMN value4 TO value1;
ALTER TABLE table_for_rename RENAME COLUMN value5 TO value2;
SHOW CREATE TABLE table_for_rename;
SELECT * FROM table_for_rename ORDER BY key;
SELECT '-- insert after rename column --';
INSERT INTO table_for_rename (date, key, value1, value2) SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1) from numbers(20,10);
SELECT * FROM table_for_rename ORDER BY key;
DROP TABLE IF EXISTS table_for_rename;

View File

@ -0,0 +1,43 @@
DROP TABLE IF EXISTS table_for_rename;
CREATE TABLE table_for_rename
(
date Date,
key UInt64,
value1 String,
value2 String,
value3 String,
CONSTRAINT cs_value1 CHECK toInt64(value1) < toInt64(value2),
CONSTRAINT cs_value2 CHECK toInt64(value2) < toInt64(value3)
)
ENGINE = MergeTree()
PARTITION BY date
ORDER BY key;
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number + 2) from numbers(9);
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number) from numbers(9); ; --{serverError 469}
SELECT * FROM table_for_rename ORDER BY key;
ALTER TABLE table_for_rename RENAME COLUMN value1 TO value4;
ALTER TABLE table_for_rename RENAME COLUMN value2 TO value5;
SHOW CREATE TABLE table_for_rename;
SELECT * FROM table_for_rename ORDER BY key;
SELECT '-- insert after rename --';
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number + 2) from numbers(10, 10);
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number) from numbers(10, 10); ; --{serverError 469}
SELECT * FROM table_for_rename ORDER BY key;
SELECT '-- rename columns back --';
ALTER TABLE table_for_rename RENAME COLUMN value4 TO value1;
ALTER TABLE table_for_rename RENAME COLUMN value5 TO value2;
SHOW CREATE TABLE table_for_rename;
SELECT * FROM table_for_rename ORDER BY key;
SELECT '-- insert after rename column --';
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number + 2) from numbers(20,10);
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number), toString(number + 2) from numbers(20, 10); ; --{serverError 469}
SELECT * FROM table_for_rename ORDER BY key;
DROP TABLE IF EXISTS table_for_rename;