planTester.buildPlan("b = load 'b' as (url,rank);");
planTester.buildPlan("c = cogroup a by url, b by url;");
LogicalPlan lp = planTester.buildPlan("d = foreach c generate group,flatten(a),flatten(b);");
//check cogroup required fields
LOCogroup cogroup = (LOCogroup)lp.getSuccessors(lp.getRoots().get(0)).get(0);
assertTrue(cogroup.getRelevantInputs(0, 0).size() == 2);
RequiredFields cogroupRelevantFields00 = cogroup.getRelevantInputs(0, 0).get(0);
assertTrue(cogroupRelevantFields00.getNeedAllFields() == false);
assertTrue(cogroupRelevantFields00.getNeedNoFields() == false);
assertTrue(cogroupRelevantFields00.getFields().size() == 1);
assertTrue(cogroupRelevantFields00.getFields().get(0).first == 0);
assertTrue(cogroupRelevantFields00.getFields().get(0).second == 0);
RequiredFields cogroupRelevantFields01 = cogroup.getRelevantInputs(0, 0).get(1);
assertTrue(cogroupRelevantFields01.getNeedAllFields() == false);
assertTrue(cogroupRelevantFields01.getNeedNoFields() == false);
assertTrue(cogroupRelevantFields01.getFields().size() == 1);
assertTrue(cogroupRelevantFields01.getFields().get(0).first == 1);
assertTrue(cogroupRelevantFields01.getFields().get(0).second == 0);
assertTrue(cogroup.getRelevantInputs(0, 1).size() == 2);
RequiredFields cogroupRelevantFields1 = cogroup.getRelevantInputs(0, 1).get(0);
assertTrue(cogroupRelevantFields1.getNeedAllFields() == true);
assertTrue(cogroupRelevantFields1.getNeedNoFields() == false);
assertTrue(cogroupRelevantFields1.getFields() == null);
assertTrue(cogroup.getRelevantInputs(0, 1).get(1) == null);
RequiredFields cogroupRelevantFields2 = cogroup.getRelevantInputs(0, 2).get(1);
assertTrue(cogroupRelevantFields2.getNeedAllFields() == true);
assertTrue(cogroupRelevantFields2.getNeedNoFields() == false);
assertTrue(cogroupRelevantFields2.getFields() == null);
assertTrue(cogroup.getRelevantInputs(0, 2).get(0) == null);
LOForEach foreach = (LOForEach)lp.getLeaves().get(0);
RequiredFields foreachRelevantFields0 = foreach.getRelevantInputs(0, 0).get(0);
assertTrue(foreachRelevantFields0.getNeedAllFields() == false);
assertTrue(foreachRelevantFields0.getNeedNoFields() == false);