ClickHouse / ClickHouse/ClickHouse

Materialized view modification query adds fields, inner table structure needs to be added

Open
#47,391 1 comment 0 reactions 0 assignees View on GitHub
comp-materialized-view external feature
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

Materialized view modification query adds fields, inner table structure needs to be added
```

CREATE TABLE src_table (`a` UInt32, `b` UInt32) ENGINE = MergeTree ORDER BY a;
CREATE MATERIALIZED VIEW mv (`a` UInt32) ENGINE = MergeTree ORDER BY a AS SELECT a FROM src_table;
INSERT INTO src_table (a, b) VALUES (1, 1), (2, 2);
SELECT * FROM mv;

┌─a─┐
│ 1 │
│ 2 │
└───┘

SET allow_experimental_alter_materialized_view_structure = 1;
ALTER TABLE mv MODIFY QUERY SELECT a, b FROM src_table;
INSERT INTO src_table (a, b) VALUES (3, 3), (4, 4);
SELECT * FROM mv
┌─a─┐
│ 1 │
│ 2 │
└───┘
┌─a─┐
│ 3 │
│ 4 │
└───┘
```

> A clear and concise description of what is the intended usage scenario is.

**Describe the solution you'd like**

In the simple case, if Query adds a field, it checks whether the field in the inner table exists
In the complex case, if Query adds a field, it adds a field in the corresponding inner table

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.