Package org.apache.pig.impl.logicalLayer

Examples of org.apache.pig.impl.logicalLayer.LogicalPlan


    }
   
    public void testCogroup() throws VisitorException, IOException {
        System.out.println("testCogroup");
      String query = "cogroup (load 'a') by ($0 + $1, $0 - $1), (load 'b') by ($0 + $1, $0 - $1);";
      LogicalPlan plan = buildPlan(query);
      PhysicalPlan pp = buildPhysicalPlan(plan);
     
     
      int MAX_SIZE = 100000;
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here


    }
   
    public void testArithmetic() throws VisitorException, IOException, ExecException {
     
      String query = "foreach (load 'A') generate $0 + $1 + '5', $0 - '5' - $1, 'hello';";
      LogicalPlan lp = buildPlan(query);
     
      PhysicalPlan pp = buildPhysicalPlan(lp);
     
        //Ensure that there is only 1 leaf node
      assertEquals(1, pp.getLeaves().size());
View Full Code Here

        assertEquals(compiledPlan, goldenPlan);
    }
   
    public void testComparison() throws VisitorException, IOException {
      String query = "filter (load 'a' using " + PigStorage.class.getName() + "(':')) by $0 + $1 > ($0 - $1) * ('4' / '2');";
      LogicalPlan lp = buildPlan(query);
      PhysicalPlan pp = buildPhysicalPlan(lp);
     
        //Ensure that there is only 1 leaf node
      assertEquals(1, pp.getLeaves().size());
     
View Full Code Here

    }

    @Test
    public void testBinCond() throws VisitorException, IOException {
        String query = "foreach (load 'a') generate ($1 == '3'? $2 + $3 : $2 - $3) ;";
        LogicalPlan lp = buildPlan(query);

        PhysicalPlan pp = buildPhysicalPlan(lp);

       
        int MAX_SIZE = 100000;
View Full Code Here

   
   
    @Test
    public void testGenerate() throws VisitorException, IOException {
        String query = "foreach (load 'a') generate ($1+$2), ($1-$2), ($1*$2), ($1/$2), ($1%$2), -($1) ;";
        LogicalPlan lp = buildPlan(query);

        PhysicalPlan pp = buildPhysicalPlan(lp);

       
        int MAX_SIZE = 100000;
View Full Code Here

    }

    @Test
    public void testUnion() throws VisitorException, IOException {
      String query = "union (load 'a'), (load 'b'), (load 'c');";
      LogicalPlan lp = buildPlan(query);
      PhysicalPlan pp = buildPhysicalPlan(lp);
     
      int MAX_SIZE = 100000;
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
        pp.explain(baos);
View Full Code Here

    }
   
    @Test
    public void testSplit() throws VisitorException, IOException {
      String query = "split (load 'a') into x if $0 < '7', y if $0 > '7';";
      LogicalPlan plan = buildPlan(query);
     
      PhysicalPlan pp = buildPhysicalPlan(plan);
     
      int MAX_SIZE = 100000;
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

    public void testIsNull() throws VisitorException, IOException {
        //TODO
        //PONot is not implemented. The query below translates to POIsNull istead
        //of PONOt(POIsNull)
      String query = "split (load 'a') into x if $0 IS NULL, y if $0 IS NOT NULL;";
      LogicalPlan plan = buildPlan(query);
     
      PhysicalPlan pp = buildPhysicalPlan(plan);
     
      int MAX_SIZE = 100000;
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

        planTester.buildPlan("a = load 'file1' using PigStorage(':') as (name:chararray, marks:int);");
        planTester.buildPlan("b = load 'file2' using PigStorage(':') as (name:chararray, rank:chararray);");
        planTester.buildPlan("c = cogroup a by name, b by name;");
        planTester.buildPlan("d = foreach c generate group, FLATTEN(a.marks) as newmarks;");
        planTester.buildPlan("e = cogroup a by marks, d by newmarks;");
        LogicalPlan plan = planTester.buildPlan("f = foreach e generate group, flatten(a), flatten(d);");
       
        // Set the logical plan values correctly in all the operators
        PlanSetter ps = new PlanSetter(plan);
        ps.visit();
       
        // run through validator
        CompilationMessageCollector collector = new CompilationMessageCollector() ;
        TypeCheckingValidator typeValidator = new TypeCheckingValidator() ;
        typeValidator.validate(plan, collector) ;       
        printMessageCollector(collector) ;
        printTypeGraph(plan) ;
       
        if (collector.hasError()) {
            throw new Exception("Error during type checking") ;
        }

        // this will run ImplicitSplitInserter
        TestLogicalOptimizer.optimizePlan(plan);
       
        // get Schema of leaf and compare:
        Schema expectedSchema = Util.getSchemaFromString("grp: int,A::username: chararray,A::marks: int,AB::group: chararray,AB::newmarks: int");
        assertTrue(Schema.equals(expectedSchema, plan.getLeaves().get(0).getSchema(),false, true));
    }
View Full Code Here

            } else if (storePred instanceof LOSplitOutput) {
                LOSplitOutput splitOutput = (LOSplitOutput)storePred;
                // We assume this is the LOSplitOutput we injected for this case:
                // b = order a by $0; store b into '1'; store b into '2';
                // In this case, we should mark both '1' and '2' as sorted
                LogicalPlan conditionPlan = splitOutput.getConditionPlan();
                if (conditionPlan.getRoots().size()==1) {
                    LogicalOperator root = conditionPlan.getRoots().get(0);
                    if (root instanceof LOConst) {
                        Object value = ((LOConst)root).getValue();
                        if (value instanceof Boolean && (Boolean)value==true) {
                            LogicalOperator split = splitOutput.getPlan().getPredecessors(splitOutput).get(0);
                            if (split instanceof LOSplit)
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.LogicalPlan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.