原表:
| a | b |
|---|---|
| Andy | <碟中谍>,<谍影重重>,<007> |
| MOMO | <小鞋子>,<朋友啊你的家在哪里> |
实现效果
| a | b |
|---|---|
| Andy | <碟中谍> |
| Andy | <谍影重重> |
| Andy | <007> |
| MOMO | <小鞋子> |
| MOMO | <朋友啊你的家在哪里> |
实现代码:
sql
select a
,film_list
from tb_name
lateral view explode(split(b,',')) t as film_list
;
注:explode函数:处理map结构的字段,将数组转换成多行,所以此处使用了split函数将b列转为array数组类型。