aschema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.BYTEARRAY));
aschema.addField(new LogicalSchema.LogicalFieldSchema("d", null, DataType.BYTEARRAY));
LOLoad load = new LOLoad(new FileSpec("file:///test/d.txt", new FuncSpec("org.apache.pig.builtin.PigStorage")), aschema, expected);
expected.add(load);
LOForEach foreach = new LOForEach(expected);
org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan = new org.apache.pig.experimental.logical.relational.LogicalPlan();
LOInnerLoad l1 = new LOInnerLoad(innerPlan, foreach, 0);
innerPlan.add(l1);
LOInnerLoad l2 = new LOInnerLoad(innerPlan, foreach, 1);
List<LogicalExpressionPlan> eps = new ArrayList<LogicalExpressionPlan>();
LogicalExpressionPlan p1 = new LogicalExpressionPlan();
p1.add(new ProjectExpression(p1, DataType.BYTEARRAY, 0, 0));
LogicalExpressionPlan p2 = new LogicalExpressionPlan();
p2.add(new ProjectExpression(p2, DataType.BYTEARRAY, 1, 0));
eps.add(p1);
eps.add(p2);
LOGenerate gen = new LOGenerate(innerPlan, eps, new boolean[] {false, true});
innerPlan.add(gen);
innerPlan.connect(l1, gen);
innerPlan.connect(l2, gen);
foreach.setInnerPlan(innerPlan);
expected.add(foreach);
LOStore s = new LOStore(expected, new FileSpec("file:///test/empty", new FuncSpec("org.apache.pig.builtin.PigStorage")));
expected.add(s);
expected.connect(load, foreach);
expected.connect(foreach, s);
try {
UidStamper stamper = new UidStamper(expected);
stamper.visit();
}catch(Exception e) {
throw new VisitorException(e);
}
assertTrue(expected.isEqual(newPlan));
LogicalSchema schema = foreach.getSchema();
aschema = new LogicalSchema();
aschema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.BYTEARRAY));
aschema.addField(new LogicalSchema.LogicalFieldSchema("d", null, DataType.BYTEARRAY));
assertTrue(schema.isEqual(aschema));
}