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

Method simpleMultiQueryTest3

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

Source from the content-addressed store, hash-verified

433 }
434
435 @Test
436 public void simpleMultiQueryTest3() throws Exception {
437 final String INPUT_FILE_2 = "input2";
438 final String OUTPUT_FILE_2 = "output2";
439
440 PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE_2));
441 w.println("3\t4\t5");
442 w.println("5\t6\t7");
443 w.println("3\t7\t8");
444 w.close();
445 Util.copyFromLocalToCluster(cluster, INPUT_FILE_2, INPUT_FILE_2);
446 new File(INPUT_FILE_2).delete();
447
448 w = new PrintWriter(new FileWriter(PIG_FILE));
449 w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
450 w.println("A1 = load '" + INPUT_FILE_2 + "' as (a0:int, a1:int, a2:int);");
451 w.println("B = filter A by a0 == 3;");
452 w.println("C = filter A by a1 <=5;");
453 w.println("D = join C by a0, B by a0, A1 by a0 using 'replicated';");
454 w.println("store C into '" + OUTPUT_FILE + "';");
455 w.println("store D into '" + OUTPUT_FILE_2 + "';");
456 w.close();
457
458 try {
459 String[] args = null;
460 args = new String[]{"-x", execType, PIG_FILE};
461 PigStats stats = PigRunner.run(args, new TestNotificationListener(execType));
462 assertTrue(stats.isSuccessful());
463 if (Util.isMapredExecType(cluster.getExecType())) {
464 assertEquals(3, stats.getJobGraph().size());
465 } else if (Util.isSparkExecType(cluster.getExecType())) {
466 // One for each store and 3 for join.
467 assertEquals(4, stats.getJobGraph().size());
468 } else {
469 assertEquals(1, stats.getJobGraph().size());
470 }
471
472 // Each output file should include the following:
473 // output:
474 // 1\t2\t3\n
475 // 5\t3\t4\n
476 // 3\t4\t5\n
477 // output2:
478 // 3\t4\t5\t3\t4\t5\t3\t4\t5\n
479 // 3\t4\t5\t3\t4\t5\t3\t7\t8\n
480 // 3\t4\t5\t3\t7\t8\t3\t4\t5\n
481 // 3\t4\t5\t3\t4\t5\t3\t7\t8\n
482 final int numOfRecords1 = 3;
483 final int numOfRecords2 = 4;
484 final int numOfBytesWritten1 = 18;
485 final int numOfBytesWritten2 = 72;
486
487 assertEquals(numOfRecords1 + numOfRecords2, stats.getRecordWritten());
488 assertEquals(numOfBytesWritten1 + numOfBytesWritten2, stats.getBytesWritten());
489
490 List<String> outputNames = new ArrayList<String>(stats.getOutputNames());
491 assertTrue(outputNames.size() == 2);
492 Collections.sort(outputNames);

Callers

nothing calls this directly

Calls 15

runMethod · 0.95
isSuccessfulMethod · 0.95
isMapredExecTypeMethod · 0.95
getJobGraphMethod · 0.95
isSparkExecTypeMethod · 0.95
getRecordWrittenMethod · 0.95
getBytesWrittenMethod · 0.95
getOutputNamesMethod · 0.95
getNumberRecordsMethod · 0.95
getInputStatsMethod · 0.95
deleteFileMethod · 0.95

Tested by

no test coverage detected