hive partion 键 关联(join)其他表

本文介绍在Hive中如何正确使用分区键关联不同表的方法。强调分区键应当在FROM子句中处理而非ON子句,并通过示例对比了两种不同写法产生的结果差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 ;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值