How to groupby key for custom class dataset in spark java

41 Views Asked by At

I have a class

public class Employee {
  int id;
  String name;
  String address;
}

...and a Dataset<Employee> in Spark, for example

Employee(1,"test1","test1")
Employee(1,"test2","test2")
Employee(2,"test3","test3")

Expected result

1---> [Employee(1,"test1","test1"),Employee(1,"test2","test2")]
2--->. Employee(2,"test3","test3")

I.e. I need to group the dataset by one of the fields (id), and get the result as a list of objects. How can I do this using Spark Java API.

0

There are 0 best solutions below