-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Alter of nullable columns to not nullable is not supported #5985
Copy link
Copy link
Closed
Labels
comp-datatype-wrapperType modifiers/wrappers (Nullable, LowCardinality, etc.).Type modifiers/wrappers (Nullable, LowCardinality, etc.).feature
Description
create table XXX (x Nullable(String), y String) engine=MergeTree order by tuple();
insert into XXX (y) values ('a');
select * from XXX
┌─x────┬─y─┐
│ ᴺᵁᴸᴸ │ a │
└──────┴───┘
ALTER TABLE XXX MODIFY COLUMN x String;
DB::Exception: Cannot convert NULL value to non-Nullable type.
ALTER TABLE XXX MODIFY COLUMN x String DEFAULT 'xxx';
DB::Exception: Cannot convert NULL value to non-Nullable type.
alter table XXX update x ='xxx' where 1;
select * from XXX
┌─x───┬─y─┐
│ xxx │ a │
└─────┴───┘
ALTER TABLE XXX MODIFY COLUMN x String;
DB::Exception: Cannot convert NULL value to non-Nullable type
Though,
drop table XXX;
create table XXX (x Nullable(String), y String) engine=MergeTree order by tuple();
ALTER TABLE XXX MODIFY COLUMN x String DEFAULT 'xxx';
Ok.
DESCRIBE TABLE XXX
┌─name─┬─type───┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ x │ String │ DEFAULT │ 'xxx' │ │ │ │
│ y │ String │ │ │ │ │ │
└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
comp-datatype-wrapperType modifiers/wrappers (Nullable, LowCardinality, etc.).Type modifiers/wrappers (Nullable, LowCardinality, etc.).feature