posexplode和explode的区别

备注:explode(x)和posexplode()均为炸裂函数,区别在于explode炸出一个值,posexplode不仅炸出一个值还附带索引号

举例:

select
split(col1,",")[idx] as col1 ,type as col2
from test t
lateral view posexplode(split(col2,",")) t1 as idx, type -- idx为list(split(col2,","))中对应的每个索引,另外一个list根据该索引取值,就能做到一一匹配

 

posted @ 2023-07-27 21:09  数据驱动  阅读(114)  评论(0编辑  收藏  举报