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

Method simpleMultiQueryTest

test/org/apache/pig/test/TestPigRunner.java:323–375  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

321 }
322
323 @Test
324 public void simpleMultiQueryTest() throws Exception {
325 final String OUTPUT_FILE_2 = "output2";
326
327 PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
328 w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
329 w.println("B = filter A by a0 >= 4;");
330 w.println("C = filter A by a0 < 4;");
331 w.println("store B into '" + OUTPUT_FILE_2 + "';");
332 w.println("store C into '" + OUTPUT_FILE + "';");
333 w.close();
334
335 try {
336 String[] args = { "-x", execType, PIG_FILE };
337 PigStats stats = PigRunner.run(args, new TestNotificationListener(execType));
338 assertTrue(stats.isSuccessful());
339 if (execType.equals("spark")) {
340 // In spark mode,the number of spark job is calculated by the number of POStore.
341 // 2 POStore generates 2 spark jobs.
342 assertTrue(stats.getJobGraph().size() == 2);
343 } else {
344 assertTrue(stats.getJobGraph().size() == 1);
345 }
346
347 // Each output file should include the following:
348 // output:
349 // 1\t2\t3\n
350 // 3\t4\t5\n
351 // 3\t7\t8\n
352 // output2:
353 // 5\t3\t4\n
354 // 5\t6\t7\n
355 final int numOfRecords = 5;
356 final int numOfCharsPerRecord = 6;
357 assertEquals(numOfRecords, stats.getRecordWritten());
358 assertEquals(numOfRecords * numOfCharsPerRecord, stats.getBytesWritten());
359 assertTrue(stats.getOutputNames().size() == 2);
360 for (String fname : stats.getOutputNames()) {
361 assertTrue(fname.equals(OUTPUT_FILE) || fname.equals(OUTPUT_FILE_2));
362 if (fname.equals(OUTPUT_FILE)) {
363 assertEquals(3, stats.getNumberRecords(fname));
364 } else {
365 assertEquals(2, stats.getNumberRecords(fname));
366 }
367 }
368 assertEquals("A,B,C",
369 ((JobStats)stats.getJobGraph().getSinks().get(0)).getAlias());
370 } finally {
371 new File(PIG_FILE).delete();
372 Util.deleteFile(cluster, OUTPUT_FILE);
373 Util.deleteFile(cluster, OUTPUT_FILE_2);
374 }
375 }
376
377 @Test
378 public void simpleMultiQueryTest2() throws Exception {

Callers

nothing calls this directly

Calls 15

runMethod · 0.95
isSuccessfulMethod · 0.95
getJobGraphMethod · 0.95
getRecordWrittenMethod · 0.95
getBytesWrittenMethod · 0.95
getOutputNamesMethod · 0.95
getNumberRecordsMethod · 0.95
deleteFileMethod · 0.95
closeMethod · 0.65
sizeMethod · 0.65
getAliasMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected