The dataset looks like this:
| id | result | rank |
|---|---|---|
| 001 | pass | 2 |
| 002 | fail | 3 |
| 001 | fail | 1 |
| 002 | pass | 1 |
What I want to do: group the dataset by id and concatenate the results in ascending order of rank column.
| id | results |
|---|---|
| 001 | fail-pass |
| 002 | pass-fail |
As the other column's order is involved, the concat_ws('-',collect_set(result))function cannot fulfill my thought.
Are there any built-in functions to help me achieve this or writing a UDF seems the only solution?