hive> select *from hanga;
OK
a b
104399 1715131_2105395_1758844_981085_2444143_1458638_968412
104400 1609001_2986088_1795054
explode的用法是将b列按照_切完之后炸裂,然后选择要炸裂出来的列
hive> select a,pos from hanga lateral view explode(split(b,'_')) t as pos ;
OK
a pos
104399 1715131
104399 2105395
104399 1758844
104399 981085
104399 2444143
104399 1458638
104399 968412
104400 1609001
104400 2986088
104400 1795054
posexplode的用法是将b列按照_切完之后炸裂,会比explode多出一列序号列 pos,
hive> select a,pos,tos from hanga lateral view posexplode(split(b,'_')) t as pos,tos ;
OK
a pos tos
104399 0 1715131
104399 1 2105395
104399 2 1758844
104399 3 981085
104399 4 2444143
104399 5 1458638
104399 6 968412
104400 0 1609001
104400 1 2986088
104400 2 1795054
leteral view explode 和posexplode的区别
最新推荐文章于 2024-07-18 22:45:00 发布