聚合模型创建物化视图,查询的子句不能用非key的字段吗

Viewed 27

有张聚合表
CREATE TABLE IF NOT EXISTS test
(
v_1 VARCHAR(150) NOT NULL,
v_2 VARCHAR(20) REPLACE NULL DEFAULT "0",
cnt BIGINT SUM DEFAULT "0",
max_dwell_time INT MAX DEFAULT "0",
min_dwell_time INT MIN DEFAULT "99999"
)
AGGREGATE KEY(v_1)
DISTRIBUTED BY HASH(v_1) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);

想对以下查询
select v_2 from test group by v_2;
创建物化视图

1 Answers

创建同步物化视图的时候必须带上key列,非key列,要按照原来的聚合类型写聚合函数
参考文档:https://doris.apache.org/zh-CN/docs/query/view-materialized-view/materialized-view/