2017-05-14 56 views
0

我已經使用側視圖在單個表(大小約12GB)上的單個查詢中多次(約9次)爆炸。這產生了大量的地圖邊數據(100Pb +)。我無法理解它是如何產生12GB的這一數據量的。蜂巢側視圖爆炸內部機制

有人可以請解釋如何橫向爆炸工程(內部)?

在此先感謝

回答

1

演示

create table mytable (a1 array<int>,a2 array<int>,a3 array<int>); 
insert into mytable select array(1,2),array(3,4,5),array(6,7,8,9); 

select * 

from mytable 
     lateral view explode (a1) e1 as a1_val 
     lateral view explode (a2) e2 as a2_val 
     lateral view explode (a3) e3 as a3_val 
;   

+-------+---------+-----------+--------+--------+--------+ 
| a1 | a2 | a3  | a1_val | a2_val | a3_val | 
+-------+---------+-----------+--------+--------+--------+ 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  3 |  6 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  3 |  7 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  3 |  8 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  3 |  9 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  4 |  6 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  4 |  7 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  4 |  8 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  4 |  9 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  5 |  6 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  5 |  7 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  5 |  8 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  1 |  5 |  9 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  3 |  6 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  3 |  7 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  3 |  8 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  3 |  9 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  4 |  6 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  4 |  7 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  4 |  8 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  4 |  9 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  5 |  6 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  5 |  7 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  5 |  8 | 
| [1,2] | [3,4,5] | [6,7,8,9] |  2 |  5 |  9 | 
+-------+---------+-----------+--------+--------+--------+  
+0

嘟嘟嗨,謝謝回答。我想知道橫向視圖的內部機制爆炸以及Hive如何在內部執行查詢。 –

+0

內部與您的問題無關。數組爆炸會爲每個元素生成一條記錄。多個數組爆炸相當於產品連接。 –

+0

對不起,我忘了。謝謝。 –