注释:即使两个表join,一个里面的都是唯一的,一个是包含重复的值的话依然会造成笛卡尔积
hive> desc tmp.0703testxhh;
OK
name string
diqu string
Time taken: 0.123 seconds, Fetched: 2 row(s)
hive> select * from tmp.0703testxhh;
OK
zs bj
zs sh
zs sh
zs sh
ls hn
ww sh
Time taken: 0.151 seconds, Fetched: 6 row(s)
hive> select *
> from(
> select
> name,
> diqu
> from tmp.0703testxhh
> )A left join(
> select
> name,
> diqu
> from tmp.0703testxhh
> )B on A.name=B.name;
OK
zs sh zs bj
zs sh zs sh
zs sh zs sh
zs sh zs sh
ls hn ls hn
ww sh ww sh
zs bj zs bj
zs bj zs sh
zs bj zs sh
zs bj zs sh
zs sh zs bj
zs sh zs sh
zs sh zs sh
zs sh zs sh
zs sh zs bj
zs sh zs sh
zs sh zs sh
zs sh zs sh
Time taken: 25.986 seconds, Fetched: 18 row(s)
hive> select *
> from(
> select
> name,
> diqu
> from tmp.0703testxhh
> )A join(
> select
> name,
> diqu
> from tmp.0703testxhh
> )B on A.name=B.name;
OK
zs bj zs sh
zs sh zs sh
zs sh zs sh
zs sh zs sh
ls hn ls hn
ww sh ww sh
zs bj zs bj
zs sh zs bj
zs sh zs bj
zs sh zs bj
zs bj zs sh
zs sh zs sh
zs sh zs sh
zs sh zs sh
zs bj zs sh
zs sh zs sh
zs sh zs sh
zs sh zs sh
Time taken: 24.778 seconds, Fetched: 18 row(s)
hive>
网友评论