Package org.apache.pig.test.utils

Examples of org.apache.pig.test.utils.LogicalPlanTester


       
    }
   
    @Test
    public void testNonRegularOuterJoinFailure() {
        LogicalPlanTester lpt = new LogicalPlanTester();
        lpt.buildPlan("a = load 'a.txt' as (n:chararray, a:int); ");
        lpt.buildPlan("b = load 'b.txt' as (n:chararray, m:chararray); ");
        String[] types = new String[] { "left", "right", "full" };
        String[] joinTypes = new String[] { "replicated", "repl"};
        for (int i = 0; i < types.length; i++) {
            for(int j = 0; j < joinTypes.length; j++) {
                boolean errCaught = false;
                try {
                    lpt.buildPlanThrowExceptionOnError("d = join a by $0 " +
                     types[i] + " outer, b by $0 using '" + joinTypes[j] +"';");
                   
                } catch(Exception e) {
                    errCaught = true;
                     // This after adding support of LeftOuter Join to replicated Join
View Full Code Here


    }
   
    @Test
    public void testLiteralsForJoinAlgoSpecification1() {
       
        LogicalPlanTester lpt = new LogicalPlanTester();
        lpt.buildPlan("a = load 'A'; ");
        lpt.buildPlan("b = load 'B'; ");
        LogicalPlan lp = lpt.buildPlan("c = Join a by $0, b by $0 using 'merge'; ");
        assertEquals(JOINTYPE.MERGE, ((LOJoin)lp.getLeaves().get(0)).getJoinType());
    }
View Full Code Here

    }
   
    @Test
    public void testLiteralsForJoinAlgoSpecification2() {
       
        LogicalPlanTester lpt = new LogicalPlanTester();
        lpt.buildPlan("a = load 'A'; ");
        lpt.buildPlan("b = load 'B'; ");
        LogicalPlan lp = lpt.buildPlan("c = Join a by $0, b by $0 using 'hash'; ");
        assertEquals(JOINTYPE.HASH, ((LOJoin)lp.getLeaves().get(0)).getJoinType());
    }
View Full Code Here

    }
   
    @Test
    public void testLiteralsForJoinAlgoSpecification5() {
       
        LogicalPlanTester lpt = new LogicalPlanTester();
        lpt.buildPlan("a = load 'A'; ");
        lpt.buildPlan("b = load 'B'; ");
        LogicalPlan lp = lpt.buildPlan("c = Join a by $0, b by $0 using 'default'; ");
        assertEquals(JOINTYPE.HASH, ((LOJoin)lp.getLeaves().get(0)).getJoinType());
    }
View Full Code Here

    }
   
    @Test
    public void testLiteralsForJoinAlgoSpecification3() {
       
        LogicalPlanTester lpt = new LogicalPlanTester();
        lpt.buildPlan("a = load 'A'; ");
        lpt.buildPlan("b = load 'B'; ");
        LogicalPlan lp = lpt.buildPlan("c = Join a by $0, b by $0 using 'repl'; ");
        assertEquals(JOINTYPE.REPLICATED, ((LOJoin)lp.getLeaves().get(0)).getJoinType());
    }
View Full Code Here

    }
   
    @Test
    public void testLiteralsForJoinAlgoSpecification4() {
       
        LogicalPlanTester lpt = new LogicalPlanTester();
        lpt.buildPlan("a = load 'A'; ");
        lpt.buildPlan("b = load 'B'; ");
        LogicalPlan lp = lpt.buildPlan("c = Join a by $0, b by $0 using 'replicated'; ");
        assertEquals(JOINTYPE.REPLICATED, ((LOJoin)lp.getLeaves().get(0)).getJoinType());
    }
View Full Code Here

    public void testGroupConstWithParallel() throws Throwable {
        PigContext pc = new PigContext(ExecType.MAPREDUCE, cluster.getProperties());
        pc.defaultParallel = 100;
        pc.connect();
       
        LogicalPlanTester planTester = new LogicalPlanTester() ;
        planTester.buildPlan("a = load 'input';");
        LogicalPlan lp = planTester.buildPlan("b = group a by 1;");
       
        PhysicalPlan pp = Util.getNewOptimizedPhysicalPlan(lp, pc);
        POStore store = GenPhyOp.dummyPigStorageOp();
        pp.addAsLeaf(store);
        MROperPlan mrPlan = Util.buildMRPlan(pp, pc);
View Full Code Here

    public void testGroupNonConstWithParallel() throws Throwable {
        PigContext pc = new PigContext(ExecType.MAPREDUCE, cluster.getProperties());
        pc.defaultParallel = 100;
        pc.connect();
       
        LogicalPlanTester planTester = new LogicalPlanTester() ;
        planTester.buildPlan("a = load 'input';");
        LogicalPlan lp = planTester.buildPlan("b = group a by $0;");
       
        PhysicalPlan pp = Util.getNewOptimizedPhysicalPlan(lp, pc);
        POStore store = GenPhyOp.dummyPigStorageOp();
        pp.addAsLeaf(store);
        MROperPlan mrPlan = Util.buildMRPlan(pp, pc);
View Full Code Here

     *
     * @throws IOException
     */
    @Test  
    public void testSimple() throws IOException  {
        LogicalPlanTester lpt = new LogicalPlanTester( pc );
        lpt.buildPlan( "A = load 'file.txt' as (a, b, c);" );
        lpt.buildPlan( "B = foreach A generate a+b, c-b;" );
        lpt.buildPlan( "C = foreach B generate $0+5, $1;" );
        org.apache.pig.impl.logicalLayer.LogicalPlan plan = lpt.buildPlan( "store C into 'empty';" )
        LogicalPlan newLogicalPlan = migratePlan( plan );
       
        int forEachCount1 = getForEachOperatorCount( newLogicalPlan );
        int outputExprCount1 = getOutputExprCount( newLogicalPlan );
        LOForEach foreach1 = getForEachOperator( newLogicalPlan );
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testComplex() throws IOException {
        LogicalPlanTester lpt = new LogicalPlanTester( pc );
        lpt.buildPlan( "A = load 'file.txt' as (a:int, b, c:bag{t:tuple(c0:int,c1:int)});" );
        lpt.buildPlan( "B = foreach A { S = ORDER c BY $0; generate $0, COUNT(S), SUM(S); };" );
        lpt.buildPlan( "C = foreach B generate $2+5 as x, $0-$1/2 as y;" );
        org.apache.pig.impl.logicalLayer.LogicalPlan plan = lpt.buildPlan( "store C into 'empty';" )
        LogicalPlan newLogicalPlan = migratePlan( plan );
       
        int forEachCount1 = getForEachOperatorCount( newLogicalPlan );
        int outputExprCount1 = getOutputExprCount( newLogicalPlan );
        LOForEach foreach1 = getForEachOperator( newLogicalPlan );
View Full Code Here

TOP

Related Classes of org.apache.pig.test.utils.LogicalPlanTester

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.