ClickHouse / ClickHouse

ClickHouse® is a real-time analytics DBMS
https://clickhouse.com
Apache License 2.0
37.52k stars 6.9k forks source link

How to add column for nested struct? #68315

Open strive-run opened 2 months ago

strive-run commented 2 months ago

Company or project name

No response

Question

create table with

set flatten_nested = 0;
CREATE TABLE nested_test
(
    `id`           Int64,
    `nested_field` Nested(a DateTime, b Int32)
) ENGINE = ReplicatedReplacingMergeTree order by id

then I want to add column nested_field.c with

alter table nested_test add column nested_field.c Array(Int16);

and execute error:

 Code: 36. DB::Exception: Columns 'nested_field Nested(c Int16)' and 'nested_field Nested(a DateTime, b Int32)' have streams (nested_field.size0 and nested_field.size0) with collision in file name nested_field.size0. (BAD_ARGUMENTS) (version 24.3.3.102 (official build))

How to add the column ? Please help me

realyota commented 2 months ago
ALTER TABLE nested_test
    (MODIFY COLUMN `nested_field` Nested(a DateTime, b Int32, c Int32))