我有两个Hive中的字符串数组,如下所示:
{'value1','value2','value3'}
{'value1', 'value2'}
我想合并数组并去除重复项,结果如下:
{'value1','value2','value3'}
我该如何在Hive中操作呢?
SELECT id, collect_set(item)
FROM table
LATERAL VIEW explode(list) lTable AS item
GROUP BY id;
CREATE TEMPORARY FUNCTION combine AS 'brickhouse.udf.collect.CombineUDF';
CREATE TEMPORARY FUNCTION combine_unique AS 'brickhouse.udf.collect.CombineUniqueUDAF';
select combine_unique(combine(array('a','b','c'), array('b','c','d'))) from reqtable;
OK
["d","b","c","a"]