org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
LogicalRelationalOperator ld = (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
assertEquals( LOLoad.class, ld.getClass() );
LOLoad load = (LOLoad)ld;
LogicalSchema ls = load.getSchema();
PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
assertEquals( POForEach.class, pFE.getClass() );
POForEach pForEach = (POForEach)pFE;
PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
assertEquals(1, ls.getField(0).uid);
assertEquals(2, ls.getField(1).uid);
LogicalRelationalOperator fe =
(LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
assertEquals( LOForEach.class, fe.getClass() );
LOForEach forEach = (LOForEach)fe;
org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan =
forEach.getInnerPlan();
assertEquals( 1, innerPlan.getSinks().size() );
assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
assertEquals( 1, gen.getOutputPlans().size() );
LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
assertEquals( 1, genExp.getSources().size() );
// Main Tests start here
assertEquals( SubtractExpression.class, genExp.getSources().get(0).getClass() );
SubtractExpression add = (SubtractExpression) genExp.getSources().get(0);
assertEquals( ls.getField(0).uid, add.getLhs().getUid() );
assertEquals( ls.getField(1).uid, add.getRhs().getUid() );
assertTrue( ls.getField(0).uid != add.getUid() );
assertTrue( ls.getField(1).uid != add.getUid() );
assertEquals( 1, inputPln.getLeaves().size() );
assertEquals( Subtract.class, inputPln.getLeaves().get(0).getClass() );
Subtract pSubtract = (Subtract) inputPln.getLeaves().get(0);
assertEquals( 2, inputPln.getRoots().size() );