前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >pig基本语法——join

pig基本语法——join

作者头像
Java架构师必看
发布2021-05-14 11:19:57
2740
发布2021-05-14 11:19:57
举报
文章被收录于专栏:Java架构师必看

pig基本语法——join

强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码

主要参考:

https://book.itxueyuan.com/3b7D/PDLO

1、基础数据:

==============================================

[root@cdh1 data]# cat demodata

xiaoxiao,12,12.1f

aaa,13,1.1f

kjkj,12,12.1f

ddf,19,12.8f

youyou,89,12.3f

[root@cdh1 data]# cat demodata2

xiaoxiao,99,aaaaaaaaaaaa

aaa,88,bbbbbbbbbbb

kjkj,77,ccccccccccc

ddf,66,dddddddddd

xuexue,11,sdfsdfsdfsdf

==============================================

2、innerjoin

grunt> A = load '/root/xytest/pig/data/demodata' using PigStorage(',') as (name:chararray,age:int,gpa:float);

grunt> B = load '/root/xytest/pig/data/demodata2' using PigStorage(',') as (name:chararray,score:int,address:chararray);

grunt> C = join A by name,B by name;

grunt> dump C;

输出结果:

(aaa,13,1.1,aaa,88,bbbbbbbbbbb)

(ddf,19,12.8,ddf,66,dddddddddd)

(kjkj,12,12.1,kjkj,77,ccccccccccc)

(xiaoxiao,12,12.1,xiaoxiao,99,aaaaaaaaaaaa)

3、left outer join

grunt> A = load '/root/xytest/pig/data/demodata' using PigStorage(',') as (name:chararray,age:int,gpa:float);

grunt> B = load '/root/xytest/pig/data/demodata2' using PigStorage(',') as (name:chararray,score:int,address:chararray);

grunt> D = join A by name left,B by name;

grunt> dump D;

输出结果:

(aaa,13,1.1,aaa,88,bbbbbbbbbbb)

(ddf,19,12.8,ddf,66,dddddddddd)

(kjkj,12,12.1,kjkj,77,ccccccccccc)

(youyou,89,12.3,,,)

(xiaoxiao,12,12.1,xiaoxiao,99,aaaaaaaaaaaa)

4、right outer join

grunt> A = load '/root/xytest/pig/data/demodata' using PigStorage(',') as (name:chararray,age:int,gpa:float);

grunt> B = load '/root/xytest/pig/data/demodata2' using PigStorage(',') as (name:chararray,score:int,address:chararray);

grunt> E = join A by name right,B by name;

grunt> dump E;

输出结果:

(aaa,13,1.1,aaa,88,bbbbbbbbbbb)

(ddf,19,12.8,ddf,66,dddddddddd)

(kjkj,12,12.1,kjkj,77,ccccccccccc)

(,,,xuexue,11,sdfsdfsdfsdf)

(xiaoxiao,12,12.1,xiaoxiao,99,aaaaaaaaaaaa)

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档