Reputation: 61
I'm working with a ClickHouse database and facing a challenge related to table structure modification and data backfilling. We use a materialized view to populate a table, and we need to add a new column to it. The data is inserted by an external component. Here's a simplified scenario:
Current Table "some_table" Structure:
Columns: A, B
Existing Data:
Column A | Column B |
---|---|
a1 | b1 |
a2 | b2 |
Materialized View:
CREATE MATERIALIZED VIEW IF NOT EXISTS some_mv ON CLUSTER default TO some_table
AS
SELECT A, B
FROM some_source_table
GROUP BY A, B
Add a new column C.
Alter the materialized view to also update column C
Backfill existing rows and ensure new rows auto-populate this column.
Resulting Table:
Column A | Column B | Column C |
---|---|---|
a1 | b1 | c1 |
a2 | b2 | c2 |
... | ... | ... |
aN | bN | cN |
Any guidance or best practices on handling this type of task would be greatly appreciated.
Thank you!
Upvotes: 1
Views: 329