assertEquals("result value", result, res.result);
}
@Test
public void testBagToOther() throws IOException, ParserException {
POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
op.setFuncSpec(new FuncSpec(PigStorage.class.getName()));
POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
PhysicalPlan plan = new PhysicalPlan();
plan.add(prj);
plan.add(op);
plan.connect(prj, op);
prj.setResultType(DataType.BAG);
TupleFactory tf = TupleFactory.getInstance();
//Plan to test when result type is ByteArray and casting is requested
//for example casting of values coming out of map lookup.
POCast opWithInputTypeAsBA = new POCast(new OperatorKey("", r.nextLong()), -1);
PhysicalPlan planToTestBACasts = constructPlan(opWithInputTypeAsBA);
{
Tuple t = tf.newTuple();
t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
plan.attachInput(t);
Map map = null;
Result res = op.getNextMap();
assertEquals(POStatus.STATUS_ERR, res.returnStatus);
}
{
Tuple t = tf.newTuple();
t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
plan.attachInput(t);
Result res = op.getNextTuple();
assertEquals(POStatus.STATUS_ERR, res.returnStatus);
}
{
Tuple t = tf.newTuple();
t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
plan.attachInput(t);
DataBag b = (DataBag) t.get(0);
Result res = op.getNextDataBag();
//System.out.println(res.result + " : " + t);
assertEquals(b, res.result);
planToTestBACasts.attachInput(t);
res = opWithInputTypeAsBA.getNextDataBag();
assertEquals(b, res.result);
}
{
Tuple t = tf.newTuple();