()
| 290 | } |
| 291 | |
| 292 | @Test |
| 293 | public void testFullOuterJoin() throws Exception { |
| 294 | String[] input1 = { |
| 295 | "hello\t1", |
| 296 | "bye\t2", |
| 297 | "\t3" |
| 298 | }; |
| 299 | String[] input2 = { |
| 300 | "hello\tworld", |
| 301 | "good\tmorning", |
| 302 | "\tevening" |
| 303 | |
| 304 | }; |
| 305 | |
| 306 | String firstInput = createInputFile("a.txt", input1); |
| 307 | String secondInput = createInputFile("b.txt", input2); |
| 308 | List<Tuple> expectedResults = Util.getTuplesFromConstantTupleStrings( |
| 309 | new String[] { |
| 310 | "(null,null,null,'evening')" , |
| 311 | "(null,null,'good','morning')" , |
| 312 | "('hello',1,'hello','world')" , |
| 313 | "('bye',2,null,null)" , |
| 314 | "(null,3,null,null)" |
| 315 | }); |
| 316 | // with and without optional outer |
| 317 | for(int i = 0; i < 2; i++) { |
| 318 | // with schema |
| 319 | String script = "a = load '"+ Util.encodeEscape(firstInput) +"' as (n:chararray, a:int); " + |
| 320 | "b = load '"+ Util.encodeEscape(secondInput) +"' as (n:chararray, m:chararray); "; |
| 321 | if(i == 0) { |
| 322 | script += "c = join a by $0 full outer, b by $0;" ; |
| 323 | } else { |
| 324 | script += "c = join a by $0 full, b by $0;" ; |
| 325 | } |
| 326 | script += "d = order c by $1, $3;"; |
| 327 | // ensure we parse correctly |
| 328 | Util.buildLp(pigServer, script); |
| 329 | |
| 330 | // run query and test results only once |
| 331 | if(i == 0) { |
| 332 | Util.registerMultiLineQuery(pigServer, script); |
| 333 | Iterator<Tuple> it = pigServer.openIterator("d"); |
| 334 | int counter= 0; |
| 335 | while(it.hasNext()) { |
| 336 | assertEquals(expectedResults.get(counter++), it.next()); |
| 337 | } |
| 338 | assertEquals(expectedResults.size(), counter); |
| 339 | |
| 340 | // without schema |
| 341 | script = "a = load '"+ Util.encodeEscape(firstInput) +"'; " + |
| 342 | "b = load '"+ Util.encodeEscape(secondInput) +"'; " ; |
| 343 | if(i == 0) { |
| 344 | script += "c = join a by $0 full outer, b by $0;" ; |
| 345 | } else { |
| 346 | script += "c = join a by $0 full, b by $0;" ; |
| 347 | } |
| 348 | try { |
| 349 | Util.registerMultiLineQuery(pigServer, script); |
nothing calls this directly
no test coverage detected