- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Hive- Convert all values for a column to a comma separated string.
- Labels:
-
Apache Hive
Created 08-24-2017 08:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Select name, city from people;
The above query results:
jon Atlanta
jon Newyork
snow LA
snow DC
But i want the result as a single row as follows:
jon Atlanta,Newyork
snow LA,DC
Created 08-24-2017 08:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the collect_set UDAF function in hive.
select name, collect_set(city) from people group by name;
collect_Set will remove all duplicates.
If you need the duplicates then you must use "collect_list".
Created 08-24-2017 08:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the collect_set UDAF function in hive.
select name, collect_set(city) from people group by name;
collect_Set will remove all duplicates.
If you need the duplicates then you must use "collect_list".
Created 08-24-2017 10:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you..!!
It worked.
