Hive No partition predicate found for Alias xxx 解决方案

来源:互联网 发布:猴王竞猜网站源码 编辑:程序博客网 时间:2024/05/17 07:04

 No partition predicate found for Alias "b" Table "user_browse_region"

在Hive中联表查询,数据量比较大,对一个表指定了分区字段,而另一个是放到联表查询的条件,导致报错。

出错的sql:

select count(a.user_id), count(distinct a.user_id) from ugc_action_raw a join user b on a.user_id=b.id join user_browse_region c on a.user_id=c.id and a.log_date=c.log_date where a.ugc_type=0 and b.gender='男生' and b.stage='20' and c.region='北京' and a.log_date='2012-09-11';

原因分析:没有对c表指定分区字段。

解决方案:联表查询的条件中去掉a.log_date=c.log_date,在后面的where语句中加上c.log_date='2012-09-11';

正确的sql:

select count(a.user_id), count(distinct a.user_id) from ugc_action_raw a join user b on a.user_id=b.id join user_browse_region c on a.user_id=c.id where a.ugc_type=0 and b.gender='男生' and b.stage='20' and c.region='北京' and a.log_date='2012-09-11' and c.log_date='2012-09-11';