I have following setup:
CREATE TABLE IF NOT EXISTS request_income_buffer (
timestamp UInt64,
timestamp_micro Float32,
traceId Int64,
host String,
type String,
service String,
message String,
caller String,
context String
) ENGINE = Kafka('kafka:9092', 'request_income', 'group', 'JSONEachRow');
CREATE MATERIALIZED VIEW IF NOT EXISTS request_income
ENGINE = MergeTree(date, microtime, 8192) AS
SELECT
toDate(toDateTime(timestamp)) AS `date`,
toDateTime(timestamp) as `date_time`,
timestamp,
timestamp_micro AS `microtime`,
traceId,
host,
type,
service,
message,
caller,
context
FROM
request_income_buffer;
I want to add new column, ex. ip
to my request_income
table.
According to docs in order to do so I will need to follow next steps:
Detach view to stop receiving messages from Kafka.
DETACH TABLE request_income;
Drop table that streams data from Kafka since Kafka engine doesn't support
ALTER
queries.DROP TABLE request_income_buffer
Recreate table that streams data from Kafka with new field.
CREATE TABLE IF NOT EXISTS request_income_buffer ( timestamp UInt64, timestamp_micro Float32, traceId Int64, host String, ip String, type String, service String, message String, caller String, context String ) ENGINE = Kafka('kafka:9092', 'request_income', 'group', 'JSONEachRow');
According to this post update .inner table of the detached materialized view
ALTER TABLE `.inner.request_income` ADD COLUMN ip String AFTER host;
According to post from above update view's select query
- Attach view
ATTACH TABLE request_income
Question is how to update view's select query?
ReplicatedMergeTree
family? – Lsd