()
| 375 | } |
| 376 | |
| 377 | @Test |
| 378 | public void simpleMultiQueryTest2() throws Exception { |
| 379 | final String OUTPUT_FILE_2 = "output2"; |
| 380 | |
| 381 | PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE)); |
| 382 | w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);"); |
| 383 | w.println("B = filter A by a0 >= 4;"); |
| 384 | w.println("C = filter A by a0 < 4;"); |
| 385 | w.println("D = group C by a0;"); |
| 386 | w.println("E = foreach D generate group, COUNT(C);"); |
| 387 | w.println("store B into '" + OUTPUT_FILE_2 + "';"); |
| 388 | w.println("store E into '" + OUTPUT_FILE + "';"); |
| 389 | w.close(); |
| 390 | |
| 391 | try { |
| 392 | String[] args = { "-x", execType, PIG_FILE }; |
| 393 | PigStats stats = PigRunner.run(args, new TestNotificationListener(execType)); |
| 394 | assertTrue(stats.isSuccessful()); |
| 395 | if (execType.equals("spark")) { |
| 396 | // In spark mode,the number of spark job is calculated by the number of POStore. |
| 397 | // 2 POStore generates 2 spark jobs. |
| 398 | assertEquals(stats.getJobGraph().size(), 2); |
| 399 | } else { |
| 400 | assertEquals(stats.getJobGraph().size(), 1); |
| 401 | } |
| 402 | |
| 403 | // Each output file should include the following: |
| 404 | // output: |
| 405 | // 5\t3\t4\n |
| 406 | // 5\t6\t7\n |
| 407 | // output2: |
| 408 | // 1\t1\n |
| 409 | // 3\t2\n |
| 410 | final int numOfRecords1 = 2; |
| 411 | final int numOfRecords2 = 2; |
| 412 | final int numOfCharsPerRecord1 = 6; |
| 413 | final int numOfCharsPerRecord2 = 4; |
| 414 | assertEquals(numOfRecords1 + numOfRecords2, stats.getRecordWritten()); |
| 415 | assertEquals((numOfRecords1 * numOfCharsPerRecord1) + (numOfRecords2 * numOfCharsPerRecord2), |
| 416 | stats.getBytesWritten()); |
| 417 | assertTrue(stats.getOutputNames().size() == 2); |
| 418 | for (String fname : stats.getOutputNames()) { |
| 419 | assertTrue(fname.equals(OUTPUT_FILE) || fname.equals(OUTPUT_FILE_2)); |
| 420 | if (fname.equals(OUTPUT_FILE)) { |
| 421 | assertEquals(2, stats.getNumberRecords(fname)); |
| 422 | } else { |
| 423 | assertEquals(2, stats.getNumberRecords(fname)); |
| 424 | } |
| 425 | } |
| 426 | assertEquals("A,B,C,D,E", |
| 427 | ((JobStats)stats.getJobGraph().getSinks().get(0)).getAlias()); |
| 428 | } finally { |
| 429 | new File(PIG_FILE).delete(); |
| 430 | Util.deleteFile(cluster, OUTPUT_FILE); |
| 431 | Util.deleteFile(cluster, OUTPUT_FILE_2); |
| 432 | } |
| 433 | } |
| 434 |
nothing calls this directly
no test coverage detected