单个LATERAL VIEW:
源表(table1)数据{A:string B:arrayC:string}
A B C
190 [1030,1031,1032,1033,1190] select id
191 [1030,1031,1032,1033,1190] select id
希望的结果是:
190 1030 select id
190 1031 select id
190 1032 select id
190 1033 select id
190 1190 select id
191 1030 select id
191 1031 select id
191 1032 select id
191 1033 select id
191 1190 select id
故使用select A,B,C from table_1 LATERAL VIEW explode(B) table1 as B得到上述结果
多个LATERAL VIEW的介绍:
LATERAL VIEW clauses are applied in the order that they appear. For example with the following base table:

Arraycol1
Arraycol2
[1, 2]
[a", "b", "c"]
[3, 4]
[d", "e", "f"]
SELECTmyCol1, myCol2FROMbaseTable
LATERALVIEWexplode(col1) myTable1ASmyCol1
LATERALVIEWexplode(col2) myTable2ASmyCol2;
结果如下:
int myCol1
string myCol2
"a"
"b"
"c"
"a"
"b"
"c"
"d"
"e"
"f"
"d"
"e"
"f"
复杂方式:
select * from tb_split;
20141018 aa|bb 7|9|0|3
20141019 cc|dd 6|1|8|5
使用方式:select datenu,des,type from tb_split
lateral view explode(split(des,"//|")) tb1 as des
lateral view explode(split(type,"//|")) tb2 as type
执行过程是先执行from到as cloumn的列过程,在执行select 和where后边的语句;