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

Method testGetNextNullInput

test/org/apache/pig/test/TestUnion.java:194–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192 // meant only for "root 2". In the former case, "root 2" would
193 // neither get input attached to it nor does it have predecessors
194 @Test
195 public void testGetNextNullInput() throws Exception {
196 File f1 = Util.createInputFile("tmp", "a.txt", new String[] {"1\t2\t3", "4\t5\t6"});
197 File f2 = Util.createInputFile("tmp", "b.txt", new String[] {"7\t8\t9", "1\t200\t300"});
198 File f3 = Util.createInputFile("tmp", "c.txt", new String[] {"1\t20\t30"});
199 //FileLocalizer.deleteTempFiles();
200 pigServer.registerQuery("a = load '" + Util.encodeEscape(f1.getAbsolutePath()) + "' ;");
201 pigServer.registerQuery("b = load '" + Util.encodeEscape(f2.getAbsolutePath()) + "';");
202 pigServer.registerQuery("c = union a, b;");
203 pigServer.registerQuery("d = load '" + Util.encodeEscape(f3.getAbsolutePath()) + "' ;");
204 pigServer.registerQuery("e = cogroup c by $0 inner, d by $0 inner;");
205 pigServer.explain("e", System.err);
206 // output should be
207 // (1,{(1,2,3),(1,200,300)},{(1,20,30)})
208 Tuple expectedResult = new DefaultTuple();
209 expectedResult.append(new DataByteArray("1"));
210 Tuple[] secondFieldContents = new DefaultTuple[2];
211 secondFieldContents[0] = Util.createTuple(Util.toDataByteArrays(new String[] {"1", "2", "3"}));
212 secondFieldContents[1] = Util.createTuple(Util.toDataByteArrays(new String[] {"1", "200", "300"}));
213 DataBag secondField = Util.createBag(secondFieldContents);
214 expectedResult.append(secondField);
215 DataBag thirdField = Util.createBag(new Tuple[]{Util.createTuple(Util.toDataByteArrays(new String[]{"1", "20", "30"}))});
216 expectedResult.append(thirdField);
217 Iterator<Tuple> it = pigServer.openIterator("e");
218 assertEquals(expectedResult, it.next());
219 assertFalse(it.hasNext());
220 }
221
222 // Test schema merge in union when one of the fields is a bag
223 @Test

Callers

nothing calls this directly

Calls 13

createInputFileMethod · 0.95
encodeEscapeMethod · 0.95
appendMethod · 0.95
createTupleMethod · 0.95
toDataByteArraysMethod · 0.95
createBagMethod · 0.95
getAbsolutePathMethod · 0.80
openIteratorMethod · 0.80
explainMethod · 0.65
registerQueryMethod · 0.45
assertEqualsMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected