写法一:用虚表实现 WITH tbl1 as( select explode(split('G1,消费分期|G2,账单分期|G3,不分期','\\|')) as t1 ), tbl2 as ( select split(t1,',') as t2 FROM tbl1 ) select t2[0],t2[1] from tbl2;
写法二:合并嵌套子查询
select split(t1,',')[0],split(t1,',')[1] as t2 FROM ( select explode(split("G1,消费分期|G2,账单分期|G3,不分期",'\\|')) as t1)tmp;
特别注意hive中子查询的表需要加别名,否则容易报如下所示不能识别错误
版权声明:本文为weixin_52948483原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。