diff --git a/dbms/tests/queries/0_stateless/01062_alter_on_mutataion.reference b/dbms/tests/queries/0_stateless/01062_alter_on_mutataion.reference new file mode 100644 index 00000000000..ed4fa235634 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01062_alter_on_mutataion.reference @@ -0,0 +1,7 @@ +14850 +14850 +59700 +59700 +59700 +0 +0 diff --git a/dbms/tests/queries/0_stateless/01062_alter_on_mutataion.sql b/dbms/tests/queries/0_stateless/01062_alter_on_mutataion.sql new file mode 100644 index 00000000000..e59849b2d2e --- /dev/null +++ b/dbms/tests/queries/0_stateless/01062_alter_on_mutataion.sql @@ -0,0 +1,51 @@ +DROP TABLE IF EXISTS test_alter_on_mutation; + +CREATE TABLE test_alter_on_mutation +( + date Date, + key UInt64, + value String +) +ENGINE ReplicatedMergeTree('/clickhouse/tables/test_alter_on_mutation', '1') +ORDER BY key PARTITION BY date; + +INSERT INTO test_alter_on_mutation select toDate('2020-01-05'), number, toString(number) from system.numbers limit 100; +INSERT INTO test_alter_on_mutation select toDate('2020-01-06'), number, toString(number) from system.numbers limit 100; +INSERT INTO test_alter_on_mutation select toDate('2020-01-07'), number, toString(number) from system.numbers limit 100; + +SELECT sum(cast(value as UInt64)) from test_alter_on_mutation; + +ALTER TABLE test_alter_on_mutation MODIFY COLUMN value UInt64; + +SELECT sum(value) from test_alter_on_mutation; + +INSERT INTO test_alter_on_mutation select toDate('2020-01-05'), number, toString(number) from system.numbers limit 100, 100; +INSERT INTO test_alter_on_mutation select toDate('2020-01-06'), number, toString(number) from system.numbers limit 100, 100; +INSERT INTO test_alter_on_mutation select toDate('2020-01-07'), number, toString(number) from system.numbers limit 100, 100; + +OPTIMIZE TABLE test_alter_on_mutation FINAL; + +SELECT sum(value) from test_alter_on_mutation; + +ALTER TABLE test_alter_on_mutation MODIFY COLUMN value String; + +SELECT sum(cast(value as UInt64)) from test_alter_on_mutation; + +OPTIMIZE TABLE test_alter_on_mutation FINAL; + +SELECT sum(cast(value as UInt64)) from test_alter_on_mutation; + +ALTER TABLE test_alter_on_mutation ADD COLUMN value1 Float64; + +SELECT sum(value1) from test_alter_on_mutation; + +ALTER TABLE test_alter_on_mutation DROP COLUMN value; + +SELECT sum(value) from test_alter_on_mutation; -- {serverError 47} + +-- this is bug +ALTER TABLE test_alter_on_mutation ADD COLUMN value String DEFAULT '0'; + +SELECT sum(cast(value as UInt64)) from test_alter_on_mutation; + +--DROP TABLE IF EXISTS test_alter_on_mutation;