Skip to content

Alter of nullable columns to not nullable is not supported #5985

@den-crane

Description

@den-crane
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 │              │                    │         │                  │                │
└──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-datatype-wrapperType modifiers/wrappers (Nullable, LowCardinality, etc.).feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions