(String[][] data)
| 453 | |
| 454 | |
| 455 | public void definedFunctions(String[][] data) throws Throwable { |
| 456 | |
| 457 | File tmpFile=TestHelper.createTempFile(data) ; |
| 458 | PrintStream ps = new PrintStream(new FileOutputStream(tmpFile)); |
| 459 | for(int i = 0; i < 1; i++) { |
| 460 | ps.println(i); |
| 461 | } |
| 462 | ps.close(); |
| 463 | pig.registerFunction("foo", |
| 464 | new FuncSpec(MyApply.class.getName()+"('foo')")); |
| 465 | String query = "foreach (group (load '" |
| 466 | + Util.generateURI(tmpFile.toString(), pig.getPigContext()) |
| 467 | + "' using " + MyStorage.class.getName() + "()) by " |
| 468 | + MyGroup.class.getName() |
| 469 | + "('all')) generate flatten(foo($1)) ;"; |
| 470 | System.out.println(query); |
| 471 | pig.registerQuery("asdf_id = " + query); |
| 472 | Iterator<Tuple> it = pig.openIterator("asdf_id"); |
| 473 | tmpFile.delete(); |
| 474 | Tuple t; |
| 475 | int count = 0; |
| 476 | while(it.hasNext()) { |
| 477 | t = it.next(); |
| 478 | assertEquals("foo", t.get(0).toString()); |
| 479 | |
| 480 | if ( t.get(1).toString() != "" ) { |
| 481 | Integer.parseInt(t.get(1).toString()); |
| 482 | } |
| 483 | count++; |
| 484 | } |
| 485 | assertEquals(count, MyStorage.COUNT); |
| 486 | } |
| 487 | |
| 488 | |
| 489 | @Test |
no test coverage detected