LoginSignup
0
0

More than 5 years have passed since last update.

Hive0.13のUniquejoinの動作について

Posted at

HiveにUniqueJoinなるものがある。
Documentに見当たらなかったが、Jiraによると0.5.0から入っていることがわかる。
https://issues.apache.org/jira/browse/HIVE-591

クエリ例:

SELECT a.id,b.id,c.id FROM UNIQUEJOIN
PRESERVE test_a a(a.id),
PRESERVE test_b b(b.id),
PRESERVE test_c c(c.id)

test_a:
Screen Shot 2016-12-30 at 0.32.07.png

test_b:

Screen Shot 2016-12-30 at 0.36.59.png

test_c:

Screen Shot 2016-12-30 at 0.33.06.png

クエリ結果:

Screen Shot 2016-12-30 at 0.30.54.png

クエリ結果から判断すると、
PRESERVE内で指定したカラムの値の全組み合わせが出すために使える。

そのため、事前にキーをユニークにしておけば、各テーブルの歯抜けになっているキーを算出できる。

制限: test_aの部分はサブクエリにはできない(少なくともHive0.13)。

一点よくわからないのが、下のFull Outer Joinで同じ結果を出せるように思うのだけれども、これを使うメリットは他に何かあるのか・・・

select a.id, b.id, c.id
from test_a a full outer join test_b b on a.id = b.id
              full outer join test_c c on a.id = c.id
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0