Package org.apache.pig.newplan.logical.expression

Examples of org.apache.pig.newplan.logical.expression.ModExpression


    public void testModCastInsert1() throws Throwable {
        LogicalExpressionPlan plan = new LogicalExpressionPlan() ;
        ConstantExpression constant1 = new ConstantExpression(plan, 10) ;
        ConstantExpression constant2 =  new ConstantExpression(plan, 20L) ;

        ModExpression mod1 = new ModExpression(plan, constant1, constant2) ;

        // Before type checking its set correctly = PIG-421
//        assertEquals(DataType.LONG, mod1.getType()) ;

        CompilationMessageCollector collector = new CompilationMessageCollector() ;
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, null);
        expTypeChecker.visit();  
        printMessageCollector(collector) ;

        //printTypeGraph(plan) ;

        // After type checking
        System.out.println(DataType.findTypeName(mod1.getType())) ;
        assertEquals(DataType.LONG, mod1.getType()) ;

        assertTrue(mod1.getLhs() instanceof CastExpression);
        assertEquals(((CastExpression)mod1.getLhs()).getType(), DataType.LONG);
        assertTrue(((CastExpression)mod1.getLhs()).getExpression() == constant1);
    }
View Full Code Here


            // Create expression inner plan #2
            LogicalExpressionPlan innerPlan2 = new LogicalExpressionPlan() ;
            ProjectExpression project21 = new ProjectExpression(innerPlan2, 0, 0, sort1) ;

            ConstantExpression const21 = new ConstantExpression(innerPlan2, 26L) ;
            ModExpression mod21 = new ModExpression(innerPlan2, project21, const21) ;
   
            // List of innerplans
            List<LogicalExpressionPlan> innerPlans = new ArrayList<LogicalExpressionPlan>() ;
            innerPlans.add(innerPlan1) ;
            innerPlans.add(innerPlan2) ;
View Full Code Here

   
            // Create expression inner plan #2
            LogicalExpressionPlan innerPlan2 = new LogicalExpressionPlan() ;
            ProjectExpression project21 = new ProjectExpression(innerPlan2, 0, 0, sort1) ;
            ConstantExpression const21 = new ConstantExpression(innerPlan2, "26") ;
            ModExpression mod21 = new ModExpression(innerPlan2, project21, const21) ;
   
            // List of innerplans
            List<LogicalExpressionPlan> innerPlans = new ArrayList<LogicalExpressionPlan>() ;
            innerPlans.add(innerPlan1) ;
            innerPlans.add(innerPlan2) ;
View Full Code Here

       
        assertEquals( 1, genExp.getSources().size() );
       
        // Main Tests start here
        assertEquals( ModExpression.class, genExp.getSources().get(0).getClass() );
        ModExpression add = (ModExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getLhs().getFieldSchema().uid );
        assertEquals( ls.getField(1).uid, add.getRhs().getFieldSchema().uid );
        assertTrue( ls.getField(0).uid != add.getFieldSchema().uid );
        assertTrue( ls.getField(1).uid != add.getFieldSchema().uid );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( Mod.class, inputPln.getLeaves().get(0).getClass() );
        Mod pMod = (Mod) inputPln.getLeaves().get(0);
        assertEquals( 2, inputPln.getRoots().size() );
View Full Code Here

        LogicalExpressionPlan plan = new LogicalExpressionPlan() ;
        ConstantExpression constant1 = new ConstantExpression(plan, 10) ;
        ConstantExpression constant2 =  new ConstantExpression(plan, 20L) ;
        ConstantExpression constant3 =  new ConstantExpression(plan, 123) ;

        ModExpression mod1 = new ModExpression(plan, constant1, constant2) ;
        EqualExpression equal1 = new EqualExpression(plan, mod1, constant3) ;

        CompilationMessageCollector collector = new CompilationMessageCollector() ;
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, null);
        expTypeChecker.visit();

        plan.explain(System.out, "text", true);

        printMessageCollector(collector) ;
        //printTypeGraph(plan) ;

        if (collector.hasError()) {
            throw new Exception("Error during type checking") ;
        }     

        // Induction check
        assertEquals(DataType.LONG, mod1.getType()) ;
        assertEquals(DataType.BOOLEAN, equal1.getType()) ;

        // Cast insertion check
        assertEquals(DataType.LONG, mod1.getLhs().getType()) ;
        assertEquals(DataType.LONG, equal1.getRhs().getType()) ;

    }
View Full Code Here

    public void testModCastInsert1() throws Throwable {
        LogicalExpressionPlan plan = new LogicalExpressionPlan() ;
        ConstantExpression constant1 = new ConstantExpression(plan, 10) ;
        ConstantExpression constant2 =  new ConstantExpression(plan, 20L) ;

        ModExpression mod1 = new ModExpression(plan, constant1, constant2) ;

        // Before type checking its set correctly = PIG-421
//        assertEquals(DataType.LONG, mod1.getType()) ;

        CompilationMessageCollector collector = new CompilationMessageCollector() ;
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, null);
        expTypeChecker.visit();  
        printMessageCollector(collector) ;

        //printTypeGraph(plan) ;

        // After type checking
        System.out.println(DataType.findTypeName(mod1.getType())) ;
        assertEquals(DataType.LONG, mod1.getType()) ;

        assertTrue(mod1.getLhs() instanceof CastExpression);
        assertEquals(((CastExpression)mod1.getLhs()).getType(), DataType.LONG);
        assertTrue(((CastExpression)mod1.getLhs()).getExpression() == constant1);
    }
View Full Code Here

            // Create expression inner plan #2
            LogicalExpressionPlan innerPlan2 = new LogicalExpressionPlan() ;
            ProjectExpression project21 = new ProjectExpression(innerPlan2, 0, 0, sort1) ;

            ConstantExpression const21 = new ConstantExpression(innerPlan2, 26L) ;
            ModExpression mod21 = new ModExpression(innerPlan2, project21, const21) ;
   
            // List of innerplans
            List<LogicalExpressionPlan> innerPlans = new ArrayList<LogicalExpressionPlan>() ;
            innerPlans.add(innerPlan1) ;
            innerPlans.add(innerPlan2) ;
View Full Code Here

   
            // Create expression inner plan #2
            LogicalExpressionPlan innerPlan2 = new LogicalExpressionPlan() ;
            ProjectExpression project21 = new ProjectExpression(innerPlan2, 0, 0, sort1) ;
            ConstantExpression const21 = new ConstantExpression(innerPlan2, "26") ;
            ModExpression mod21 = new ModExpression(innerPlan2, project21, const21) ;
   
            // List of innerplans
            List<LogicalExpressionPlan> innerPlans = new ArrayList<LogicalExpressionPlan>() ;
            innerPlans.add(innerPlan1) ;
            innerPlans.add(innerPlan2) ;
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.logical.expression.ModExpression

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.