pig.registerQuery("d = load 'c.txt' ;");
pig.registerQuery("e = cogroup c by $0 inner, d by $0 inner;");
pig.explain("e", System.err);
// output should be
// (1,{(1,2,3),(1,200,300)},{(1,20,30)})
Tuple expectedResult = new DefaultTuple();
expectedResult.append(new DataByteArray("1"));
Tuple[] secondFieldContents = new DefaultTuple[2];
secondFieldContents[0] = Util.createTuple(Util.toDataByteArrays(new String[] {"1", "2", "3"}));
secondFieldContents[1] = Util.createTuple(Util.toDataByteArrays(new String[] {"1", "200", "300"}));
DataBag secondField = Util.createBag(secondFieldContents);
expectedResult.append(secondField);
DataBag thirdField = Util.createBag(new Tuple[]{Util.createTuple(Util.toDataByteArrays(new String[]{"1", "20", "30"}))});
expectedResult.append(thirdField);
Iterator<Tuple> it = pig.openIterator("e");
assertEquals(expectedResult, it.next());
assertFalse(it.hasNext());
}