hvie炸裂函数explode

lateral view表的关联只能和explode使用

explode炸裂函数,只能炸裂Array Map

列:select id,name,type from table_name lateral view explode(split(types,"\\|")) t as type;

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
CN_lldd
CN_sjd
CN_jp
CN_rpt
USA_yns
USA_sd
USA_ydfdf
USA_gdffd


load data local inpath "/movie.txt" into table watch;

 

 

//创建数据文件
lldq js|kh|dz|yq
sdyjq dz|js|js
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

 

posted @ 2019-05-14 15:11  玩转大数据  阅读(1253)  评论(0编辑  收藏  举报