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

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


        castFss.add(intFs);

        Schema castSchema = new Schema(castFss);


        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();
View Full Code Here


    @Test
    public void testExpressionTypeChecking10() throws Throwable {
        // test whether the equal and not equal operators can accept two boolean operands
        LogicalExpressionPlan plan = new LogicalExpressionPlan();
        ConstantExpression constant1 = new ConstantExpression(plan, 10);
        ConstantExpression constant2 = new ConstantExpression(plan, 20L);
        ConstantExpression constant3 = new ConstantExpression(plan, Boolean.TRUE);

        GreaterThanExpression gt1 = new GreaterThanExpression(plan, constant1, constant2);
        EqualExpression equal1 = new EqualExpression(plan, gt1, constant3);
        NotEqualExpression nq1 = new NotEqualExpression(plan, gt1, constant3);
View Full Code Here

    @Test
    public void testExpressionTypeCheckingFail10() throws Throwable {
        // test whether the equal and not equal operators will reject the comparison between
        // a boolean value with a value of other type
        LogicalExpressionPlan plan = new LogicalExpressionPlan();
        ConstantExpression constant1 = new ConstantExpression(plan, 10);
        ConstantExpression constant2 = new ConstantExpression(plan, 20L);
        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);
View Full Code Here

    @Test
    public void testExpressionTypeChecking11() throws Throwable {
        // test whether conditional operators can accept two datetime operands
        LogicalExpressionPlan plan = new LogicalExpressionPlan();
        ConstantExpression constant0 = new ConstantExpression(plan, new DateTime(0L));
        ConstantExpression constant1 = new ConstantExpression(plan, new DateTime("1970-01-01T00:00:00.000Z"));
        ConstantExpression constant2 = new ConstantExpression(plan, new DateTime(1L));
        ConstantExpression constant3 = new ConstantExpression(plan, new DateTime(2L));
        ConstantExpression constant4 = new ConstantExpression(plan, new DataByteArray("1970-01-01T00:00:00.003Z"));

        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);
View Full Code Here

    @Test
    public void testExpressionTypeCheckingFail11() throws Throwable {
        // test whether conditional operators will reject the operation of one
        // 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(
View Full Code Here

    }

    @Test
    public void testArithmeticOpCastInsert1() throws Throwable {
        LogicalExpressionPlan plan = new LogicalExpressionPlan();
        ConstantExpression constant1 = new ConstantExpression(plan, 10);
        ConstantExpression constant2 =  new ConstantExpression(plan, 20D);

        MultiplyExpression mul1 = new MultiplyExpression(plan,constant1, constant2);

        // Before type checking its set correctly - PIG-421
        // System.out.println(DataType.findTypeName(mul1.getType()));
View Full Code Here

    }

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

        NegativeExpression neg1 = new NegativeExpression(plan, constant1);
        SubtractExpression subtract1 = new SubtractExpression(plan, neg1, constant2);

        // Before type checking its set correctly = PIG-421
View Full Code Here

    }

    @Test
    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());
View Full Code Here

        // Positive case
        @Test
        public void testRegexTypeChecking1() throws Throwable {
            LogicalExpressionPlan plan = new LogicalExpressionPlan();
            ConstantExpression constant1 = new ConstantExpression(plan, "10");
            ConstantExpression constant2 = new ConstantExpression(plan, "Regex");

            RegexExpression regex = new RegexExpression(plan, constant1, constant2);

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

        // Positive case with cast insertion
        @Test
        public void testRegexTypeChecking2() throws Throwable {
            LogicalExpressionPlan plan = new LogicalExpressionPlan();
            ConstantExpression constant1 = new ConstantExpression(plan, new DataByteArray());
            ConstantExpression constant2 = new ConstantExpression(plan, "Regex");

            RegexExpression regex = new RegexExpression(plan, constant1, constant2);

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

TOP

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

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.