2017-08-03 92 views
-1

我有用重複值分隔的列(字符串)空間。我想刪除重複項: 如何從配置單元表中刪除字符串列中的重複項

column_name 
----------------- 
gun gun man gun man 
shuttle enemy enemy run 
hit chase 

我想導致這樣的:

column_name 
---------------- 
gun man 
shuttle enemy run 
hit chase 

我使用蜂巢database.Please幫助。

+0

的可能的複製[如何刪除蜂巢串的重複?(https://stackoverflow.com/questions/42874823/how-to-remove-duplicates-in-hive-string) –

回答

-1

沒有自定義的UDF,這是一個只有查詢的方法。

select id, concat_ws(' ',collect_set(splited)) as column_name 
from 
(
    select id, splited 
    from tbl_name 
    LATERAL VIEW explode(split(column_name,' ')) t as splited 
    group by id, splited 
) x 
group by id 
+0

非常感謝你許多。它正在工作 – Camel