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

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


        ConstantExpression constant3 = new ConstantExpression(plan, "true");

        GreaterThanExpression gt1 = new GreaterThanExpression(plan, constant1,
                constant2);
        CastExpression cast1 = new CastExpression(plan,  constant3, createFS(DataType.BYTEARRAY));
        EqualExpression equal1 = new EqualExpression(plan, gt1, cast1);
        NotEqualExpression nq1 = new NotEqualExpression(plan, gt1, cast1);

        CompilationMessageCollector collector = new CompilationMessageCollector();
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(
                plan, collector, null);
View Full Code Here


        LessThanExpression lt1 = new LessThanExpression(plan, constant1, constant2);
        LessThanEqualExpression lte1 = new LessThanEqualExpression(plan, constant1, constant2);
        GreaterThanExpression gt1 = new GreaterThanExpression(plan, constant3, constant4);
        GreaterThanEqualExpression gte1 = new GreaterThanEqualExpression(plan, constant3, constant4);
        EqualExpression eq1 = new EqualExpression(plan, constant0, constant1);
        NotEqualExpression neq1 = new NotEqualExpression(plan, constant0, constant2);

        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.BOOLEAN, lt1.getType());
        assertEquals(DataType.BOOLEAN, lte1.getType());
        assertEquals(DataType.BOOLEAN, gt1.getType());
        assertEquals(DataType.BOOLEAN, gte1.getType());
        assertEquals(DataType.BOOLEAN, eq1.getType());
        assertEquals(DataType.BOOLEAN, neq1.getType());

        // Cast insertion check
        assertEquals(DataType.DATETIME, gt1.getRhs().getType());
        assertEquals(DataType.DATETIME, gte1.getRhs().getType());
View Full Code Here

        // value of datetime and one of other type
        LogicalExpressionPlan plan = new LogicalExpressionPlan();
        ConstantExpression constant0 = new ConstantExpression(plan, new DateTime(0L));
        ConstantExpression constant1 = new ConstantExpression(plan, new DataByteArray("1970-01-01T00:00:00.000Z"));
        CastExpression cast1 = new CastExpression(plan,  constant1, createFS(DataType.BYTEARRAY));
        EqualExpression eq1 = new EqualExpression(plan, constant0, cast1);

        CompilationMessageCollector collector = new CompilationMessageCollector();
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(
                plan, collector, null);
View Full Code Here

        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

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

        GreaterThanExpression gt1 = new GreaterThanExpression(plan, constant1, constant2);
        EqualExpression equal1 = new EqualExpression(plan, gt1, constant3);

        CompilationMessageCollector collector = new CompilationMessageCollector();
        LogicalRelationalOperator dummyRelOp = createDummyRelOpWithAlias();
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, dummyRelOp);
        try {
View Full Code Here

        ConstantExpression constant1 = new ConstantExpression(plan, innerTuple);
        ConstantExpression constant2 =  new ConstantExpression(plan, tuple);
        CastExpression cast1 = new CastExpression(plan, constant1,
                org.apache.pig.newplan.logical.Util.translateFieldSchema(new FieldSchema(null, castSchema, DataType.TUPLE)));

        EqualExpression equal1 = new EqualExpression(plan, cast1, constant2);

        CompilationMessageCollector collector = new CompilationMessageCollector();

        LogicalRelationalOperator dummyRelOp = createDummyRelOpWithAlias();
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, dummyRelOp);
        expTypeChecker.visit();
        printMessageCollector(collector);
        //printTypeGraph(plan);

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

        assertEquals(DataType.BOOLEAN, equal1.getType());
        assertEquals(DataType.TUPLE, equal1.getRhs().getType());
        assertEquals(DataType.TUPLE, equal1.getLhs().getType());
    }
View Full Code Here

    @Test
    public void testBinaryOperatorOrder() throws FrontendException {
        LogicalExpressionPlan ep = new LogicalExpressionPlan();
        ConstantExpression c = new ConstantExpression(ep, new Integer(5));
        ProjectExpression p = new ProjectExpression(ep, 0, 0, null);
        EqualExpression e = new EqualExpression(ep, p, c);
        assertEquals(p, e.getLhs());
        assertEquals(c, e.getRhs());
       
    }
View Full Code Here

    @Test
    public void testExpressionPlanVisitor() throws FrontendException {
        LogicalExpressionPlan ep = new LogicalExpressionPlan();
        ConstantExpression c = new ConstantExpression(ep, new Integer(5));
        ProjectExpression p = new ProjectExpression(ep, 0, 0, null);
        EqualExpression e = new EqualExpression(ep, p, c);
        ConstantExpression c2 = new ConstantExpression(ep, new Boolean("true"));
        new AndExpression(ep, e, c2);
       
        TestExpressionVisitor v = new TestExpressionVisitor(ep);
        v.visit();
View Full Code Here

    @Test
    public void testExpressionEquality() throws FrontendException {
        LogicalExpressionPlan ep1 = new LogicalExpressionPlan();
        ConstantExpression c1 = new ConstantExpression(ep1, new Integer(5));
        ProjectExpression p1 = new ProjectExpression(ep1, 0, 0, null);
        EqualExpression e1 = new EqualExpression(ep1, p1, c1);
        ConstantExpression ca1 = new ConstantExpression(ep1, new Boolean("true"));
        AndExpression a1 = new AndExpression(ep1, e1, ca1);
       
        LogicalExpressionPlan ep2 = new LogicalExpressionPlan();
        ConstantExpression c2 = new ConstantExpression(ep2, new Integer(5));
        ProjectExpression p2 = new ProjectExpression(ep2, 0, 0, null);
        EqualExpression e2 = new EqualExpression(ep2, p2, c2);
        ConstantExpression ca2 = new ConstantExpression(ep2, new Boolean("true"));
        AndExpression a2 = new AndExpression(ep2, e2, ca2);
       
        assertTrue(ep1.isEqual(ep2));
        assertTrue(c1.isEqual(c2));
        assertTrue(p1.isEqual(p2));
        assertTrue(e1.isEqual(e2));
        assertTrue(ca1.isEqual(ca2));
        assertTrue(a1.isEqual(a2));
       
        LogicalExpressionPlan ep3 = new LogicalExpressionPlan();
        ConstantExpression c3 = new ConstantExpression(ep3, new Integer(3));
        ProjectExpression p3 = new ProjectExpression(ep3, 0, 1, null);
        EqualExpression e3 = new EqualExpression(ep3, p3, c3);
        ConstantExpression ca3 = new ConstantExpression(ep3, "true");
        AndExpression a3 = new AndExpression(ep3, e3, ca3);
       
        assertFalse(ep1.isEqual(ep3));
        assertFalse(c1.isEqual(c3));
View Full Code Here

           
            // D = filter
            LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
            ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, null);
            ConstantExpression fc = new ConstantExpression(filterPlan, new Integer(0));
            new EqualExpression(filterPlan, fy, fc);
            LOFilter D = new LOFilter(lp, filterPlan);
            D.neverUseForRealSetSchema(cschema);
            lp.add(D);
            lp.connect(C, D);
        }
       
        // Build a second similar plan to test equality
        // A = load
        LogicalPlan lp1 = new LogicalPlan();
        {
            LogicalSchema aschema = new LogicalSchema();
            aschema.addField(new LogicalSchema.LogicalFieldSchema(
                "x", null, DataType.INTEGER));
            LOLoad A = new LOLoad(new FileSpec("/abc",
                new FuncSpec(DummyLoad.class.getName(), new String[] {"x", "y"})), aschema, lp1, null);
            lp1.add(A);
           
            // B = load
            LogicalSchema bschema = new LogicalSchema();
            bschema.addField(new LogicalSchema.LogicalFieldSchema(
                "y", null, DataType.INTEGER));
            LOLoad B = new LOLoad(new FileSpec("/def",
                new FuncSpec("PigStorage", "\t")), bschema, lp1, null);
            lp1.add(B);
           
            // C = join
            LogicalSchema cschema = new LogicalSchema();
            cschema.addField(new LogicalSchema.LogicalFieldSchema(
                "x", null, DataType.INTEGER));
            cschema.addField(new LogicalSchema.LogicalFieldSchema(
                "y", null, DataType.INTEGER));
            LogicalExpressionPlan aprojplan = new LogicalExpressionPlan();
            new ProjectExpression(aprojplan, 0, 0, null);
            LogicalExpressionPlan bprojplan = new LogicalExpressionPlan();
            new ProjectExpression(bprojplan, 1, 0, null);
            MultiMap<Integer, LogicalExpressionPlan> mm =
                new MultiMap<Integer, LogicalExpressionPlan>();
            mm.put(0, aprojplan);
            mm.put(1, bprojplan);
            LOJoin C = new LOJoin(lp1, mm, JOINTYPE.HASH, new boolean[] {true, true});
            C.neverUseForRealSetSchema(cschema);
            lp1.add(C);
            lp1.connect(A, C);
            lp1.connect(B, C);
               
           
            // D = filter
            LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
            ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, null);
            ConstantExpression fc = new ConstantExpression(filterPlan, new Integer(0));
            new EqualExpression(filterPlan, fy, fc);
            LOFilter D = new LOFilter(lp1, filterPlan);
            D.neverUseForRealSetSchema(cschema);
            lp1.add(D);
            lp1.connect(C, D);
               
View Full Code Here

TOP

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

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.