Hive中Inner join、Outer join、Full join中on与where的执行计划与结果区别

本文详细探讨了在Hive 2.3中,Inner join、Outer join(Left join为例)和Full join在on条件和where条件下的执行计划和结果差异。内容包括不同join类型下,筛选条件对查询结果和执行过程的影响,揭示了Hive在底层的优化策略,如谓词下推等。
摘要由CSDN通过智能技术生成

背景

本文主要讨论hive(版本2.3)中,不同join方式下on条件和where条件的区别,同时关注hive中如何执行语句。比如谓词下推,就是其中一种优化技术。

原表

person表

person.id       person.name     person.age
3       mili    21
4       tom     19
5       mike    18
8       nul     20

account表

account.id      account.account
1       2222
2       2323
3       1111
4       1212
5       5555
6       6666

Inner join

通常情况下简写为join
inner join,查询条件在on中和where中,执行结果上并没有不同。
比如,下面几个查询语句执行结果相同

select * from person join account on person.id=account.id and person.id=4;
select * from person join account on person.id=account.id and account.id=4;
select * from person join account on person.id=account.id where person.id=4;
select * from person join account on person.id=account.id where account.id=4;
select * from person join account on person.id=account.id and person.id=4 and account.id=4;
select * from person join account on person.id=account.id where person.id=4 and account.id=4;

执行结果

person.id       person.name     person.age      account.id      account.account
4 tom 19 4 1212

通过explain查看上述执行语句转换的mapreduce任务,所有的任务都被转化为相同的执行计划:

hive (test)> explain select * from person join account on person.id=account.id and person.id=4 and account.id=4;
O
  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值