hive 表中如果需要用partion键进行关联其他表一定不要写在on中,正确写法要将partion键写在from中
例如:
insert overwrite table dc_temp1_user_score
select
a.mobile
,nvl(b.prov_des,'其他')
,nvl(b.zone_des,'其他')
from (select * from 表1 where stat_date='20160216') a
left outer join 表2 b on a.mobile = b.mobile_no ;
insert overwrite table dc_temp1_user_score
select
a.mobile
,nvl(b.prov_des,'其他')
,nvl(b.zone_des,'其他')
from 表1 a
left outer join 表2 b on a.stat_date='20160216' and a.mobile = b.mobile_no ;
两种写法第一种是正确的
第一种产生1条记录
第二种产生n条记录,n为partion分区个数
insert overwrite table dc_temp1_user_score
select
a.md5
,nvl(b.prov_des,'其他')
,nvl(b.zone_des,'其他')
,a.score
from (select * from yxt_scorecard_history where stat_date='20160216') a
left outer join dc_md5_pro b on a.md5 = b.mobile_no ;
select
a.md5
,nvl(b.prov_des,'其他')
,nvl(b.zone_des,'其他')
,a.score
from (select * from yxt_scorecard_history where stat_date='20160216') a
left outer join dc_md5_pro b on a.md5 = b.mobile_no ;