@Test
public void testReduceOnTupleWithMultipleKeyFieldSelectors() throws Exception{
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.get5TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> reduceDs = ds.
groupBy(4, 0).reduce((in1, in2) -> {
Tuple5<Integer, Long, Integer, String, Long> out = new Tuple5<>();
out.setFields(in1.f0, in1.f1 + in2.f1, 0, "P-)", in1.f4);
return out;
});
List<Tuple5<Integer, Long, Integer, String, Long>> result = reduceDs
.collect();
String expected = "1,1,0,Hallo,1\n" +
"2,3,2,Hallo Welt wie,1\n" +
"2,2,1,Hallo Welt,2\n" +
"3,9,0,P-),2\n" +
"3,6,5,BCD,3\n" +
"4,17,0,P-),1\n" +
"4,17,0,P-),2\n" +
"5,11,10,GHI,1\n" +
"5,29,0,P-),2\n" +
"5,25,0,P-),3\n";
compareResultAsTuples(result, expected);
}