I am new to scala and I have been having trouble fetching distinct text values from each cell of a row. My dataframe looks somewhat like this below. My intent is to eliminate duplicate skills for each candidate id.
| candidate_id | skills | join_date | location |
|---|---|---|---|
| 1789s3 | java; c++ ; java | 2012-09-22 | Mumbai |
| agduch23 | ppt ; ppt ; miner | 2018-02-02 | Banglore |
| sgdtev | office 365; | 2019-03-10 | Noida |
My final resultant dataframe should look somewhat like this -
| candidate_id | skills | join_date | location |
|---|---|---|---|
| 1789s3 | java; c++ | 2012-09-22 | Mumbai |
| agduch23 | ppt; miner | 2018-02-02 | Banglore |
| sgdtev | office 365; | 2019-03-10 | Noida |
I use the following command in SQL to do this.
string_agg(ARRAY_TO_STRING(ARRAY((select distinct skill from unnest(split(skills_agg, '; ')) as skill)), '; ')) as skills_distinct
Is there a way I can do this in scala without using sql.
Thanks in advance