当前位置:   article > 正文

列转行cross join unnest用法注意点_presto cross join unnest

presto cross join unnest

presto中的列转行函数cross join unnest类似于hive中的侧写表lateral view explode,可以把一行转为多行。

把name字段用逗号分割后转为多行:

select id,new_name from table

cross join unnest(split(name,','))  as tmp(new_name );

注意:

cross join unnest会自动过滤掉字段值为空的数据,要保留全部数据可以这样写:

select id,new_name from table

cross join unnest(split(name,','))  as tmp(new_name )

union all 

select id,new_name from table

where name is null;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/437560
推荐阅读
相关标签
  

闽ICP备14008679号