sparksql--join关联执行情况

本文通过实例探讨了SparkSQL中join操作的不同类型,包括left join、inner join的组合使用,分析了不同join顺序对结果的影响,并展示了执行计划的关键部分。

准备5张表的数据,例如

select * from yxl_test;
+----+-------+-----+
|  id   | name  |  val   | 
+----+-------+-----+
| 3     | au       | 90.0  | 
| 6     | pp       | 92.0  | 
| 8     | we      | 57.0  | 
| 8     | we      | 27.0  | 
| 6     |           | 85.0  | 
| 3     | tom   | 30.0  | 
| 12   |          | 78.0  | 
| NULL| jay   | 49.0  | 
| 7     | jy      | 28.0   |
| 9     |          | NULL  | 

+-------+-------+-------+


cache table yxl_test1 as select id,name,val from yxl_test order by id limit 2;

select * from yxl_test1;
+-------+-------+-------+
|  id   | name  |  val  | 
+-------+-------+-------+
| NULL  | jay   | 49.0  | 
| 3     | tom   | 30.0  |

+-------+-------+-------+

cache table yxl_test2 as select id,name,val from yxl_test order by id desc limit 2;

select * from yxl_test2;
+-----+-------+-------+--+
| id  | name  |  val  |
+-----+-------+-------+--+
| 12  |       | 78.0  |
| 9   |       | NULL  |

+-----+-------+-------+--+


cache table yxl_test3 as select id,name,val from yxl_test where id = 6;

select * from yxl_test3;
+-----+-------+-------+--+
| id  | name  |  val  |
+-----+-------+-------+--+
| 6   | pp    | 92.0  |
| 6   |       | 85.0  |

+-----+-------+-------+--+


cache table yxl_test4 as select id,name,val from yxl_test where id=3;

 select * from yxl_test4;
+-----+-------+-------+--+
| id  | name  |  val  |
+-----+-------+-------+--+
| 3   | au    | 90.0  |
| 3   | tom   | 30.0  |

+-----+-------+-------+--+


cache table yxl_test5 as select id,name,val from yxl_test where id=3 and name='au';

 select * from yxl_test5;
+-----+-------+-------+--+
| id  | name &nbs

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值