I have a PCollection of (key, value) pairs where the value is itself a list
{'apple': ['1','2'],
'watermelon': ['4','5']
'apple': ['9','10']
}
I would like to obtain another collection with the same key, but where the list is a GroupByKey on the original collection, but where the resulting value is a flattened.
{'apple': ['1','2','9','10'],
'watermelon': ['4','5']
}
instead of
{'apple': [['1','2], ['9','10']],
'watermelon': [['4','5']]
}
I have tried a few things but it's not obvious to me how to go about it.
I guess one can always write a ParDo function that flattens the list on a per-element basis but it feels there must be an easier solution.