如何在hive中获取数组中的不同元素

Sra*_*epu 2 hadoop hive

我有一个表格,每列有一列array<bigint>动态大小.例如:

          1  [100,200] 
          2  [100,300,500,600]
          3  [200,300]
Run Code Online (Sandbox Code Playgroud)

结果应该是此列数组的不同值

100
200
300
500
600
Run Code Online (Sandbox Code Playgroud)

Shi*_*war 9

你必须使用hive的explode()函数.然后在子查询上应用distinct.

就像是

select  distinct a.conver from (select explode(arr) as conver from arraytype2) as a
Run Code Online (Sandbox Code Playgroud)

希望有所帮助!