微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

hive中left outer join 的问题

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

hive> desc t1;   
OK
id                      int                                         
name                    string                                      
p_id                    int                                         
Time taken: 0.118 seconds,Fetched: 3 row(s)
hive> desc t2;
OK
id                      int                                         
name                    string                                      
Time taken: 0.051 seconds,Fetched: 2 row(s)
hive> select * from t1;
OK
1       aaa     2
2       bbb     2
3       ccc     3
4       ddd     4
5       fff     3
6       ooo     23
Time taken: 0.418 seconds,Fetched: 6 row(s)
hive> select * from t2;
OK
4       jjj
4       jjj
4       jjj
2       abc
3       hhh
4       jjj
3       ii
2       fuck
7       shit
Time taken: 0.068 seconds,Fetched: 9 row(s)
hive> select * from t1 left outer join t2 on (t1.p_id=t2.id) where t2.name='abc';

OK
1       aaa     2       2       abc
2       bbb     2       2       abc
Time taken: 21.53 seconds,Fetched: 2 row(s)
hive> select * from t1 left outer join t2 on (t1.p_id=t2.id and t2.name='abc');   

OK
1       aaa     2       2       abc
2       bbb     2       2       abc
3       ccc     3       NULL    NULL
4       ddd     4       NULL    NULL
5       fff     3       NULL    NULL
6       ooo     23      NULL    NULL
Time taken: 17.676 seconds,Fetched: 6 row(s)

hive left outer join 要过滤右表的数据应该是第二种写法,第一种是MysqL的写法,但是在hive中会存在问题。

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐