MCPcopy Create free account
hub / github.com/apache/pig / testTwoBagFlatten

Method testTwoBagFlatten

test/org/apache/pig/test/TestFlatten.java:43–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 }
42
43 @Test
44 public void testTwoBagFlatten() throws Exception {
45 Storage.Data data = Storage.resetData(pig);
46 data.set("input",
47 Storage.tuple(
48 Storage.bag(
49 Storage.tuple("a","b"),
50 Storage.tuple("c","d")),
51 Storage.bag(
52 Storage.tuple("1","2"),
53 Storage.tuple("3","4"))
54 )
55 );
56 pig.setBatchOn();
57 pig.registerQuery("A = load 'input' using mock.Storage() as (bag1:bag {(a1_1:chararray, a1_2:chararray)}, bag2:bag{(a2_1:chararray, a2_2:chararray)});");
58 pig.registerQuery("B = foreach A GENERATE FLATTEN(bag1), FLATTEN(bag2);");
59 pig.registerQuery("store B into 'output' using mock.Storage();");
60 List<ExecJob> execJobs = pig.executeBatch();
61 for( ExecJob execJob : execJobs ) {
62 assertTrue(execJob.getStatus() == ExecJob.JOB_STATUS.COMPLETED );
63 }
64 Schema expectedSch = Utils.getSchemaFromString("bag1::a1_1: chararray,bag1::a1_2: chararray,bag2::a2_1: chararray,bag2::a2_2: chararray");
65 assertEquals(expectedSch, data.getSchema("output"));
66 List<Tuple> actualResults = data.get("output");
67 List<Tuple> expectedResults = Util.getTuplesFromConstantTupleStrings(
68 new String[] {
69 "('a', 'b', '1', '2')", "('a', 'b', '3', '4')", "('c', 'd', '1', '2')", "('c', 'd', '3', '4')" });
70 Util.checkQueryOutputs(actualResults.iterator(), expectedResults);
71 }
72
73 @Test
74 public void testTwoMapFlatten() throws Exception {

Callers

nothing calls this directly

Calls 15

resetDataMethod · 0.95
tupleMethod · 0.95
bagMethod · 0.95
getSchemaFromStringMethod · 0.95
checkQueryOutputsMethod · 0.95
setMethod · 0.65
getStatusMethod · 0.65
getSchemaMethod · 0.65
getMethod · 0.65
iteratorMethod · 0.65
setBatchOnMethod · 0.45

Tested by

no test coverage detected