hive 错误 FAILED: SemanticException [Error 10041]: No partition predicate found for

使用kylin 通过hive来创建cube,在build的时候出现这个错误

FAILED: SemanticException [Error 10041]: No partition predicate found for Alias “im_opgroupchatstat” Table “im_opgroupchatstat_cube” 

出现这个问题主要是hive设置了严格模式 ,而创建cube的时候查询没有指定分区,所以报错
解决办法有
1、set hive.mapred.mode=unstrict;
指定使用非严格模式,但是hive设置了严格模式就是为了防止某些查询消耗巨大的资源,所以请慎重。
2、修改SQL在where中加上分区字段。
比如我出问题的这条SQL,没有加分区条件,直接查询全表,所以报错

INSERT OVERWRITE TABLE kylin_intermediate_im_opgroupchatstat_cube_4b1ca3ae_802b_4c80_9207_f34230123cde SELECT
IM_OPGROUPCHATSTAT.UID as IM_OPGROUPCHATSTAT_UID
,IM_OPGROUPCHATSTAT.EID as IM_OPGROUPCHATSTAT_EID
,IM_OPGROUPCHATSTAT.WORKSHEETID as IM_OPGROUPCHATSTAT_WORKSHEETID
,IM_OPGROUPCHATSTAT.NICKNAME as IM_OPGROUPCHATSTAT_NICKNAME
,IM_OPGROUPCHATSTAT.OPERATORGROUPCODE as IM_OPGROUPCHATSTAT_OPERATORGROUPCODE
,IM_OPGROUPCHATSTAT.ROLEID as IM_OPGROUPCHATSTAT_ROLEID
,IM_OPGROUPCHATSTAT.DAY_START as IM_OPGROUPCHATSTAT_DAY_START
,IM_OPGROUPCHATSTAT.MINUTE_START as IM_OPGROUPCHATSTAT_MINUTE_START
FROM PRICEENGINEDB.IM_OPGROUPCHATSTAT as IM_OPGROUPCHATSTAT 
WHERE 1=1
;

修改后加入分区字段D即可正常执行。

INSERT OVERWRITE TABLE kylin_intermediate_im_opgroupchatstat_cube_4b1ca3ae_802b_4c80_9207_f34230123cde SELECT
IM_OPGROUPCHATSTAT.UID as IM_OPGROUPCHATSTAT_UID
,IM_OPGROUPCHATSTAT.EID as IM_OPGROUPCHATSTAT_EID
,IM_OPGROUPCHATSTAT.WORKSHEETID as IM_OPGROUPCHATSTAT_WORKSHEETID
,IM_OPGROUPCHATSTAT.NICKNAME as IM_OPGROUPCHATSTAT_NICKNAME
,IM_OPGROUPCHATSTAT.OPERATORGROUPCODE as IM_OPGROUPCHATSTAT_OPERATORGROUPCODE
,IM_OPGROUPCHATSTAT.ROLEID as IM_OPGROUPCHATSTAT_ROLEID
,IM_OPGROUPCHATSTAT.DAY_START as IM_OPGROUPCHATSTAT_DAY_START
,IM_OPGROUPCHATSTAT.MINUTE_START as IM_OPGROUPCHATSTAT_MINUTE_START
FROM PRICEENGINEDB.IM_OPGROUPCHATSTAT as IM_OPGROUPCHATSTAT 
WHERE 1=1 AND (IM_OPGROUPCHATSTAT.D >= '2019-02-20' AND IM_OPGROUPCHATSTAT.D < '2019-02-21')
;

在Kylin中,对cube构建的SQL加分区字段,有一种办法是修改这个cube依赖的model,在model的settings里面设置Partition Date Column为你的hive的分区字段即可。
查看hive的分区字段 SHOW PARTITIONS tablename

你可能感兴趣的:(hive 错误 FAILED: SemanticException [Error 10041]: No partition predicate found for)