Merge pull request #23483 from hexiaoting/dev_alter_bugfix

Fix bug when modify column without type
This commit is contained in:
Maksim Kita 2021-04-23 00:24:36 +03:00 committed by GitHub
commit f27002b1be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -1578,6 +1578,7 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, Context
const IDataType * new_type = command.data_type.get();
const IDataType * old_type = old_types[command.column_name];
if (new_type)
checkVersionColumnTypesConversion(old_type, new_type, command.column_name);
/// No other checks required

View File

@ -0,0 +1 @@
CREATE TABLE default.alter_test\n(\n `a` Int32,\n `b` DateTime DEFAULT now() + 1\n)\nENGINE = ReplacingMergeTree(b)\nORDER BY a\nSETTINGS index_granularity = 8192

View File

@ -0,0 +1,6 @@
DROP TABLE IF EXISTS alter_test;
CREATE TABLE alter_test (a Int32, b DateTime) ENGINE = ReplacingMergeTree(b) ORDER BY a;
ALTER TABLE alter_test MODIFY COLUMN `b` DateTime DEFAULT now();
ALTER TABLE alter_test MODIFY COLUMN `b` DEFAULT now() + 1;
SHOW CREATE TABLE alter_test;
DROP TABLE alter_test;