I have a RDD like the following:
[
Row(device='1', token='aaa', other_value=1),
Row(device='1', token='bbb', other_value=1),
Row(device='2', token='bbb', other_value=1),
Row(device='4', token='ddd', other_value=1),
...
]
In order to do some processing (not for aggregation), I need to group rows with the same device or token together. For example, first 3 rows above should be grouped together for further processing. (row 1 and 2 have the same device 1, row 2 and 3 have the same token bbb).
Essentially, I would like to do something like
rdd.groupBy(same device or same token)
Is it possible in spark?
Update:
The expected output would be a RDD like this for the above example:
[
[
Row(device='1', token='aaa', other_value=1),
Row(device='1', token='bbb', other_value=1),
Row(device='2', token='bbb', other_value=1)
],
[
Row(device='4', token='ddd', other_value=1)
]
]