阵列相交蜂巢 [英] Array intersect Hive
本文介绍了阵列相交蜂巢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在蜂巢串的两个数组像
I have two arrays of string in Hive like
{'value1','value2','value3'}
{'value1', 'value2'}
我想没有重复合并数组,结果是:
I want to merge arrays without duplicates, result:
{'value1','value2','value3'}
我怎么能在蜂巢做呢?
How I can do it in hive?
推荐答案
您将需要一个UDF这一点。 Klout的有包下了一堆开源HivUDFS的
brickhouse。这里是 GitHub的链接。他们有一堆UDF的那正好提供你的目的。
下载,构建并添加JAR。下面是一个例子。
You will need a UDF for this. Klout has a bunch of opensource HivUDFS under the package brickhouse. Here is the github link. They have a bunch of UDF's that exactly serves your purpose. Download,build and add the JAR. Here is an example
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"]
这篇关于阵列相交蜂巢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文