diff --git a/dbms/src/Storages/AlterCommands.cpp b/dbms/src/Storages/AlterCommands.cpp index 621f56e79f4..ea85701356c 100644 --- a/dbms/src/Storages/AlterCommands.cpp +++ b/dbms/src/Storages/AlterCommands.cpp @@ -517,7 +517,7 @@ void AlterCommands::prepare(const StorageInMemoryMetadata & metadata, const Cont if (!has_column && command.if_exists) command.ignore = true; - if (has_column) + if (has_column && command.data_type) { auto column_from_table = columns.get(command.column_name); if (!command.default_expression && column_from_table.default_desc.expression) diff --git a/dbms/tests/queries/0_stateless/00079_defaulted_columns.reference b/dbms/tests/queries/0_stateless/00079_defaulted_columns.reference index 207f25399fc..03fd13f9044 100644 --- a/dbms/tests/queries/0_stateless/00079_defaulted_columns.reference +++ b/dbms/tests/queries/0_stateless/00079_defaulted_columns.reference @@ -28,13 +28,13 @@ some string 11 payload String date Date MATERIALIZED today() key UInt64 MATERIALIZED 0 * rand() -payload_length UInt16 DEFAULT length(payload) % 65535 +payload_length UInt64 DEFAULT length(payload) % 65535 hello clickhouse 16 some string 11 payload String date Date MATERIALIZED today() key UInt64 MATERIALIZED 0 * rand() -payload_length UInt16 DEFAULT CAST(length(payload), \'UInt16\') +payload_length UInt16 DEFAULT length(payload) payload String date Date MATERIALIZED today() key UInt64 MATERIALIZED 0 * rand() diff --git a/dbms/tests/queries/0_stateless/00079_defaulted_columns.sql b/dbms/tests/queries/0_stateless/00079_defaulted_columns.sql index 8137b57dcbd..77178478a4d 100644 --- a/dbms/tests/queries/0_stateless/00079_defaulted_columns.sql +++ b/dbms/tests/queries/0_stateless/00079_defaulted_columns.sql @@ -20,7 +20,7 @@ create table defaulted (payload String, date materialized today(), key materiali desc table defaulted; insert into defaulted (payload) values ('hello clickhouse'); select * from defaulted; -alter table defaulted add column payload_length materialized length(payload); +alter table defaulted add column payload_length UInt64 materialized length(payload); desc table defaulted; select *, payload_length from defaulted; insert into defaulted (payload) values ('some string'); diff --git a/dbms/tests/queries/0_stateless/00229_prewhere_column_missing.sql b/dbms/tests/queries/0_stateless/00229_prewhere_column_missing.sql index da4cce9a992..324e37bfce7 100644 --- a/dbms/tests/queries/0_stateless/00229_prewhere_column_missing.sql +++ b/dbms/tests/queries/0_stateless/00229_prewhere_column_missing.sql @@ -16,7 +16,7 @@ select *, length(arr) as l from prewhere_column_missing; select *, length(arr) as l from prewhere_column_missing where l = 0; select *, length(arr) as l from prewhere_column_missing prewhere l = 0; -alter table prewhere_column_missing add column hash_x default intHash64(x); +alter table prewhere_column_missing add column hash_x UInt64 default intHash64(x); select * from prewhere_column_missing; select * from prewhere_column_missing where hash_x = intHash64(x); diff --git a/dbms/tests/queries/0_stateless/00721_force_by_identical_result_after_merge_zookeeper.sql b/dbms/tests/queries/0_stateless/00721_force_by_identical_result_after_merge_zookeeper.sql index aa386829276..d9034c9d6cd 100644 --- a/dbms/tests/queries/0_stateless/00721_force_by_identical_result_after_merge_zookeeper.sql +++ b/dbms/tests/queries/0_stateless/00721_force_by_identical_result_after_merge_zookeeper.sql @@ -9,7 +9,7 @@ SYSTEM SYNC REPLICA byte_identical_r2; -- Add a column with a default expression that will yield different values on different replicas. -- Call optimize to materialize it. Replicas should compare checksums and restore consistency. -ALTER TABLE byte_identical_r1 ADD COLUMN y DEFAULT rand(); +ALTER TABLE byte_identical_r1 ADD COLUMN y UInt64 DEFAULT rand(); OPTIMIZE TABLE byte_identical_r1 PARTITION tuple() FINAL; SELECT x, t1.y - t2.y FROM byte_identical_r1 t1 SEMI LEFT JOIN byte_identical_r2 t2 USING x ORDER BY x; diff --git a/dbms/tests/queries/0_stateless/00916_add_materialized_column_after.sql b/dbms/tests/queries/0_stateless/00916_add_materialized_column_after.sql index b52a471b2b7..6a1f9bca955 100644 --- a/dbms/tests/queries/0_stateless/00916_add_materialized_column_after.sql +++ b/dbms/tests/queries/0_stateless/00916_add_materialized_column_after.sql @@ -1,7 +1,7 @@ DROP TABLE IF EXISTS add_materialized_column_after; CREATE TABLE add_materialized_column_after (x UInt32, z UInt64) ENGINE MergeTree ORDER BY x; -ALTER TABLE add_materialized_column_after ADD COLUMN y MATERIALIZED toString(x) AFTER x; +ALTER TABLE add_materialized_column_after ADD COLUMN y String MATERIALIZED toString(x) AFTER x; DESC TABLE add_materialized_column_after;