我有以下设置:
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;
我想添加新列,例如。ip
到my request_income
餐桌。根据文档,为了这样做,我需要执行以下步骤:
分离视图以停止接收来自 Kafka 的消息。
DETACH TABLE request_income;
删除从 Kafka 流式传输数据的表,因为 Kafka 引擎不支持
ALTER
查询。DROP TABLE request_income_buffer
使用新字段重新创建从 Kafka 流式传输数据的表。
如果不存在则创建表 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' , '组', 'JSONEachRow');
根据this post更新分离物化视图的.inner表
ALTER TABLE `.inner.request_income` 在主机之后添加列 ip 字符串;
根据上面更新视图的选择查询的帖子
- 附加视图
附加表 request_income
问题是如何更新视图的选择查询?