【已解决】2.1.0版本异步物化视图使用分区失败

Viewed 168

创建表:

CREATE TABLE test (
a tinyint(4) NULL DEFAULT "0" ,
b int(11) DEFAULT "0" ,
c int(11) DEFAULT "0" ,
t DATETIMEV2 COMMENT "时间",
d bigint(20) SUM NULL DEFAULT "0",
e bigint(20) SUM NULL DEFAULT "0"
)
AGGREGATE KEY(a, b, c, t)
PARTITION BY RANGE(t) ()
DISTRIBUTED BY HASH(a) BUCKETS AUTO
PROPERTIES
(
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.start" = "-3",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"dynamic_partition.create_history_partition" = "true",
"dynamic_partition.history_partition_num" = "3",
"dynamic_partition.replication_num" = "2",
"light_schema_change" = "true"
);

创建异步物化视图:

CREATE MATERIALIZED VIEW mv_test 
BUILD DEFERRED 
REFRESH AUTO 
ON SCHEDULE EVERY 2 MINUTE 
PARTITION BY (t) 
DISTRIBUTED BY RANDOM BUCKETS 2 
 PROPERTIES ( 
"replication_num" = "1"

 ) 
AS 
SELECT a,b,t,SUM(d) FROM test GROUP BY 1,2,3

报错:
image.png

官网文档这些条件应该都是满足的:
image.png

请问一下我是哪里没有搞对吗?

1 Answers

哈喽,您好,文档这里缺个约束条件,内表的基表分区字段需要是 not null属性, hive 外表对于null属性没有限制,可以为空也可以不为空
所以您将 分区字段添加 not null 属性就可以了

image.png