The main difference between GroupBy and GroupByKey is that, if you want to use the topic’s key, you use “groupByKey”. If you need to group by a different field that is not the key, the you use “GroupBy”, and you will have to select a grouping key. This will internally trigger a “re-partition”, creating a new topic in Kafka to handle the change of key, so that keys are not mixed.