()
| 545 | } |
| 546 | |
| 547 | @Test |
| 548 | public void testExplainXmlComplex() throws Throwable { |
| 549 | // TODO: Explain XML output is not supported in non-MR mode. Remove the |
| 550 | // following condition once it's implemented in Tez. |
| 551 | String execType = cluster.getExecType().toString().toLowerCase(); |
| 552 | Assume.assumeTrue("Skip this test for TEZ", Util.isMapredExecType(cluster.getExecType()) || Util.isSparkExecType(cluster.getExecType())); |
| 553 | PigServer pig = new PigServer(cluster.getExecType(), properties); |
| 554 | pig.registerQuery("a = load 'a' as (site: chararray, count: int, itemCounts: bag { itemCountsTuple: tuple (type: chararray, typeCount: int, f: float, m: map[]) } ) ;") ; |
| 555 | pig.registerQuery("b = foreach a generate site, count, FLATTEN(itemCounts);") ; |
| 556 | pig.registerQuery("c = group b by site;"); |
| 557 | pig.registerQuery("d = foreach c generate FLATTEN($1);"); |
| 558 | pig.registerQuery("e = group d by $2;"); |
| 559 | |
| 560 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 561 | PrintStream ps = new PrintStream(baos); |
| 562 | pig.explain("e", "xml", true, false, ps, ps, null, null); |
| 563 | |
| 564 | ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
| 565 | DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); |
| 566 | DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); |
| 567 | Document doc = dBuilder.parse(bais); |
| 568 | |
| 569 | //Verify Logical and Physical Plans aren't supported. |
| 570 | NodeList logicalPlan = doc.getElementsByTagName("logicalPlan"); |
| 571 | assertEquals(1, logicalPlan.getLength()); |
| 572 | assertTrue(logicalPlan.item(0).getTextContent().contains("Not Supported")); |
| 573 | NodeList physicalPlan = doc.getElementsByTagName("physicalPlan"); |
| 574 | assertEquals(1, physicalPlan.getLength()); |
| 575 | assertTrue(physicalPlan.item(0).getTextContent().contains("Not Supported")); |
| 576 | |
| 577 | |
| 578 | if (execType.equals(ExecType.MAPREDUCE.name().toLowerCase())){ |
| 579 | verifyExplainXmlComplexMR(doc); |
| 580 | } else if (execType.equals(MiniGenericCluster.EXECTYPE_SPARK)){ |
| 581 | verifyExplainXmlComplexSpark(doc); |
| 582 | } |
| 583 | |
| 584 | |
| 585 | } |
| 586 | |
| 587 | private void verifyExplainXmlComplexSpark(Document doc) { |
| 588 | NodeList stores = doc.getElementsByTagName("POStore"); |
nothing calls this directly
no test coverage detected