hive複合數據類型array

數據類型array<string>函數

 

有以下數據:字段分別是movie_name, actors集合,show,字段分別以‘,’分割,第二個字段有三個元素,元素之間以:分割,所以把第二個字段設置爲array<string>。orm

戰狼2,吳京:吳剛:龍母,2017-08-16qt

三生三世十里桃花,劉亦菲:癢癢,2017-08-20string

普羅米修斯,蒼老師:小澤老師:波多老師,2017-09-17it

美女與野獸,吳剛:加藤鷹,2017-09-17io

 

建表table

create table db_hive.t_movie(movie_name string, actors array<string>, show date)form

row format delimited fields terminated by ','test

collection items terminated by ':';date

 

導數

load data local inpath "/home/arraytest.txt"

into table db_hive.t_movie;

 

查詢

array_contains函數

select * from t_movie where array_contains(actors,"龍母");

 

size函數

select movie_name,size(actors) as size,show from t_movie;

相關文章
相關標籤/搜索