split函式:
split函式:分割字串,回傳值是array
使用desc function split命令查看hive中的split的使用的基本語法,

split函式根據regex來截取字串,regex是正則運算式,
具體使用:select split(str,',') from student;
split回傳值是array,經常搭配explode使用,select explode(split(str,',')) from student;
explode函式和lateral view:
explode函式:將hive中的一列中復雜的array或者map分成多行,
功能:列轉行,
使用desc function explode命令查看hive中的split的使用的基本語法,

機翻:將陣列的元素分隔為多行,或將貼圖的元素分隔為多行和多列,
具體使用:select explode(split(str,',')) from student;
lateral view:側視圖配合explode,一個陳述句生成把單行資料拆解成多行后的資料結果集,
具體使用:
create table if not exists employee(
name string,
work_place array<string>,
gender_age struct<gender:string,age:int>,
skills_score map<string,int>,
depart_title map<string,array<string>>
)
comment 'this is an internal table'
row format delimited fields terminated by '|'
collection items terminated by ','
map keys terminated by ':'
lines terminated by '\n';
select name,skill,score from employee lateral view explode(skills_score) sk_sc as skill,score;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/356751.html
標籤:其他
