Fix bug when modify column without type

This commit is contained in:
hexiaoting 2021-04-22 14:48:57 +08:00
parent 1fcf198cec
commit d24946f475
3 changed files with 9 additions and 1 deletions

View File

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

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;