炸裂函数explode

ateral viem 表的关联只能和explode使用

hive> select explode(info) from t_map where id=1;

炸裂函数explode_第1张图片

炸裂函数explode_第2张图片

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;

炸裂函数explode_第3张图片

 

//求有几种类型
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;

炸裂函数explode_第4张图片

 

//将炸裂的数据和 表关联 lateral view
hive> select id,name,type from mv lateral view explode(split(types,"\\|")) t as type

炸裂函数explode_第5张图片

 

转载于:https://www.cnblogs.com/sx66/p/10862276.html

你可能感兴趣的:(炸裂函数explode)