lateral viem 表的關聯只能和explode使用
hive> select explode(info) from t_map where id=1;
hive> create table watch(id int,name string) row format delimited fields terminated by " ";
vim movie.txt
1 CN_lldd
2 CN_sjd
3 CN_jp
4 CN_rpt
5 USA_yns
6 USA_sd
7 USA_ydfdf
8 USA_gdffd
load data local inpath "/movie.txt" into table watch;
//創建數據文件
1 lldq js|kh|dz|yq
2 sdyjq dz|js|js
3 yw ll|yq|dz
//上傳數據
load data local inpath "/mv.txt" into table mv;
//將數據炸開
hive> select explode(split(types,"\\|")) from mv;
//求有幾種類型
hive> select count(*) from (select explode(split(types,"\\|"))type from mv) t group by t.type;
hive> select count(*),type from (select explode(split(types,"\\|"))type from mv) t group by t.type;
//將炸裂的數據和 表關聯 lateral view
hive> select id,name,type from mv lateral view explode(split(types,"\\|")) t as type