I have a dataset like below; with values of col1 repeating multiple times and unique values of col2. This original dataset can almost a billion rows, so I do not want to use collect or collect_list as it will not scale-out for my use case.
Original Dataset:
+---------------------|
| col1 | col2 |
+---------------------|
| AA| 11 |
| BB| 21 |
| AA| 12 |
| AA| 13 |
| BB| 22 |
| CC| 33 |
+---------------------|
I want to transform the dataset into the following array format. newColumn as an array of col2.
Transformed Dataset:
+---------------------|
|col1 | newColumn|
+---------------------|
| AA| [11,12,13]|
| BB| [21,22] |
| CC| [33] |
+---------------------|
I have seen this solution, but it uses collect_list and will not scale-out on big datasets.