hive中行转列的问题:

在很多情况下,我们需要将hive表中的某一列切分,转成多行,这个时候我们想到了函数explode(),比如数据:
|people|name|addr|
|小明|北京,天津
需要转换成:
|小明|北京|
|小明|天津|
这个时候用


select name , explode(split(addr,',')` from people

会报错:

SemanticException [Error 10081]: UDTF's are not supported outside the SELECT clause,
 nor nested in expressions

这个时候可以使用lateral view就可以解决问题:

select
  name,
  address 
from
  people m lateral view explode(split ( addr,
  ',')) adtable as address

你可能感兴趣的:(大数据,hive)