Package org.apache.pig.impl.logicalLayer

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


    @Test
    public void testSortInfoNoOrderBy1() throws Exception {
        LogicalPlanTester lpt = new LogicalPlanTester(pc);
        lpt.buildPlan("a = load 'bla' as (i:int, n:chararray, d:double);");
        lpt.buildPlan("b = filter a by i > 10;");
        LogicalPlan lp = lpt.buildPlan("store b into 'foo';");
        PigServer.SortInfoSetter siSetter = new PigServer.SortInfoSetter(lp);
        siSetter.visit();
        PhysicalPlan pp = buildPhysicalPlan(lp);
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        assertEquals(null, si);
View Full Code Here


    public void testSortInfoNoOrderBy2() throws Exception {
        LogicalPlanTester lpt = new LogicalPlanTester(pc);
        lpt.buildPlan("a = load 'bla' as (i:int, n:chararray, d:double);");
        lpt.buildPlan("b = order a by i, d;");
        lpt.buildPlan("c = filter b by i > 10;");
        LogicalPlan lp = lpt.buildPlan("store c into 'foo';");
        PhysicalPlan pp = buildPhysicalPlan(lp);
        PigServer.SortInfoSetter siSetter = new PigServer.SortInfoSetter(lp);
        siSetter.visit();
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        assertEquals(null, si);
View Full Code Here

    public void testSortInfoOrderByLimit() throws Exception {
        LogicalPlanTester lpt = new LogicalPlanTester(pc);
        lpt.buildPlan("a = load 'bla' as (i:int, n:chararray, d:double);");
        lpt.buildPlan("b = order a by i, d desc;");
        lpt.buildPlan("c = limit b 10;");
        LogicalPlan lp = lpt.buildPlan("store c into 'foo';");
        PigServer.SortInfoSetter siSetter = new PigServer.SortInfoSetter(lp);
        siSetter.visit();
        LOPrinter lpr = new LOPrinter(System.err, lp);
        lpr.visit();
        PhysicalPlan pp = buildPhysicalPlan(lp);
View Full Code Here

            .getDeclaredMethod("compileLp",
            new Class[] { String.class });

        compileLp.setAccessible(true);

        LogicalPlan lp = (LogicalPlan) compileLp.invoke(myPig, new Object[] { null });
        LOPrinter lpr = new LOPrinter(System.err, lp);
        lpr.visit();
       
        java.lang.reflect.Method compilePp = myPig.getClass()
            .getDeclaredMethod("compilePp",
View Full Code Here

    @Test
    public void testSortInfoNoOrderBySchema() throws Exception {
        LogicalPlanTester lpt = new LogicalPlanTester(pc);
        lpt.buildPlan("a = load 'bla' ;");
        lpt.buildPlan("b = order a by $0;");
        LogicalPlan lp = lpt.buildPlan("store b into 'foo';");
        PigServer.SortInfoSetter siSetter = new PigServer.SortInfoSetter(lp);
        siSetter.visit();
        PhysicalPlan pp = buildPhysicalPlan(lp);
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        SortInfo expected = getSortInfo(Arrays.asList(new String[] {null}),
View Full Code Here

            pigContext.connect();
           
            LogicalPlanBuilder builder = new LogicalPlanBuilder(pigContext); //


            LogicalPlan lp = builder.parse("Test-Plan-Builder",
                                           query,
                                           aliases,
                                           logicalOpTable,
                                           aliasOp,
                                           fileNameMap);
            List<LogicalOperator> roots = lp.getRoots();
           
           
            if(roots.size() > 0) {
                for(LogicalOperator op: roots) {
                    if (!(op instanceof LOLoad) && !(op instanceof LODefine)){
                        throw new Exception("Cannot have a root that is not the load or define operator. Found " + op.getClass().getName());
                    }
                }
            }
           
            System.err.println("Query: " + query);
           
            //Just the top level roots and their children
            //Need a recursive one to travel down the tree
           
            for(LogicalOperator op: lp.getRoots()) {
                System.err.println("Logical Plan Root: " + op.getClass().getName() + " object " + op);   

                List<LogicalOperator> listOp = lp.getSuccessors(op);
               
                if(null != listOp) {
                    Iterator<LogicalOperator> iter = listOp.iterator();
                    while(iter.hasNext()) {
                        LogicalOperator lop = iter.next();
View Full Code Here

            for(int i = 1; i < succs.size(); i++) {
                mPlan.disconnect(nodes.get(0), splitOp);
            }

            for (LogicalOperator succ : succs) {
                LogicalPlan condPlan = new LogicalPlan();
                LOConst cnst = new LOConst(mPlan, new OperatorKey(scope,
                        idGen.getNextNodeId(scope)), Boolean.valueOf(true));
                cnst.setType(DataType.BOOLEAN);
                condPlan.add(cnst);
                LOSplitOutput splitOutput = new LOSplitOutput(mPlan,
                        new OperatorKey(scope, idGen.getNextNodeId(scope)), ++index, condPlan);
                splitOp.addOutput(splitOutput);
                mPlan.add(splitOutput);
                mPlan.insertBetween(splitOp, splitOutput, succ);
View Full Code Here


    private void insertCast(ExpressionOperator node,
                            byte toType, FieldSchema toFs, ExpressionOperator predecessor)
    throws VisitorException {
        LogicalPlan currentPlan = mCurrentWalker.getPlan() ;
        collectCastWarning(node, predecessor.getType(), toType);

        OperatorKey newKey = genNewOperatorKey(node);
        LOCast cast = new LOCast(currentPlan, newKey, toType) ;
        try {
            if (toFs!=null)
                cast.setFieldSchema(toFs);
        } catch (FrontendException e) {
            int errCode = 2217;
            String msg = "Problem setFieldSchema for " + node + " ";
            throw new TypeCheckerException(msg, errCode, PigException.BUG, e);
        }
        currentPlan.add(cast) ;
        try {
            currentPlan.insertBetween(predecessor, cast, node);
        }
        catch (PlanException pe) {
            int errCode = 2059;
            String msg = "Problem with inserting cast operator for " + node + " in plan.";
            throw new TypeCheckerException(msg, errCode, PigException.BUG, pe);
View Full Code Here

    }

    @Override
    protected void visit(LOSplitOutput op) throws VisitorException {
        op.unsetSchema();
        LogicalPlan currentPlan =  mCurrentWalker.getPlan() ;

        // LOSplitOutput can only have 1 input
        List<LogicalOperator> list = currentPlan.getPredecessors(op) ;
        if (list.size() != 1) {
            int errCode = 2008;
            String msg = "LOSplitOutput cannot have more than one input. Found: " + list.size() + " input(s).";
            throw new TypeCheckerException(msg, errCode, PigException.BUG) ;
        }

        LogicalPlan condPlan = op.getConditionPlan() ;

        // Check that the inner plan has only 1 output port
        if (!condPlan.isSingleLeafPlan()) {
            int errCode = 1057;
            String msg = "Split's inner plan can only have one output (leaf)" ;
            msgCollector.collect(msg, MessageType.Error) ;
            throw new TypeCheckerException(msg, errCode, PigException.INPUT) ;
        }
           
        checkInnerPlan(op.getAlias(), condPlan) ;
                
        byte innerCondType = condPlan.getLeaves().get(0).getType() ;
        if (innerCondType != DataType.BOOLEAN) {
            int errCode = 1058;
            String msg = "Split's condition must evaluate to boolean. Found: " + DataType.findTypeName(innerCondType) ;
            msgCollector.collect(msg, MessageType.Error) ;
            throw new TypeCheckerException(msg, errCode, PigException.INPUT) ;
View Full Code Here

        LogicalOperator input = s.getInput() ;
       
        // Type checking internal plans.
        for(int i=0;i < s.getSortColPlans().size(); i++) {
           
            LogicalPlan sortColPlan = s.getSortColPlans().get(i) ;

            // Check that the inner plan has only 1 output port
            if (!sortColPlan.isSingleLeafPlan()) {
                int errCode = 1057;
                String msg = "Sort's inner plan can only have one output (leaf)" ;
                msgCollector.collect(msg, MessageType.Error) ;
                throw new TypeCheckerException(msg, errCode, PigException.INPUT) ;
            }
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.