Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Function


                new ArrayType(DataTypes.STRING));
        List<Symbol> arguments = Arrays.<Symbol>asList(
                term,
                Literal.newLiteral(3)
        );
        Function function = createFunction(SubscriptFunction.NAME, DataTypes.STRING, arguments);
        SubscriptFunction subscriptFunction = (SubscriptFunction) functions.get(function.info().ident());

        Symbol result = subscriptFunction.normalizeSymbol(function);
        assertThat(result, isLiteral(null, DataTypes.STRING));
    }
View Full Code Here


    @Test
    public void testNormalizeSymbol() {
        EqOperator op = getOp(DataTypes.INTEGER);

        Function function = new Function(
                op.info(), Arrays.<Symbol>asList(Literal.newLiteral(2), Literal.newLiteral(2)));
        Symbol result = op.normalizeSymbol(function);

        assertLiteralSymbol(result, true);
    }
View Full Code Here

    }

    @Test
    public void testNormalizeSymbolWithNullLiteral() {
        EqOperator op = getOp(DataTypes.INTEGER);
        Function function = new Function(
                op.info(), Arrays.<Symbol>asList(Literal.NULL, Literal.NULL));
        Literal result = (Literal)op.normalizeSymbol(function);
        assertNull(result.value());
        assertEquals(DataTypes.UNDEFINED, result.valueType());
    }
View Full Code Here

    }

    @Test
    public void testNormalizeSymbolWithOneNullLiteral() {
        EqOperator op = getOp(DataTypes.INTEGER);
        Function function = new Function(
                op.info(), Arrays.<Symbol>asList(Literal.newLiteral(2), Literal.NULL));
        Literal result = (Literal)op.normalizeSymbol(function);
        assertNull(result.value());
        assertEquals(DataTypes.UNDEFINED, result.valueType());
    }
View Full Code Here

    @Test
    public void testNormalizeSymbolNeq() {
        EqOperator op = getOp(DataTypes.INTEGER);

        Function function = new Function(
                op.info(), Arrays.<Symbol>asList(Literal.newLiteral(2), Literal.newLiteral(4)));
        Symbol result = op.normalizeSymbol(function);

        assertLiteralSymbol(result, false);
    }
View Full Code Here

    }

    @Test
    public void testNormalizeSymbolNonLiteral() {
        EqOperator op = getOp(DataTypes.INTEGER);
        Function f1 = new Function(
                new FunctionInfo(
                        new FunctionIdent("dummy_function", Arrays.<DataType>asList(DataTypes.INTEGER)),
                        DataTypes.INTEGER
                ),
                Arrays.<Symbol>asList(Literal.newLiteral(2))
        );

        Function f2 = new Function(
                new FunctionInfo(
                        new FunctionIdent("dummy_function", Arrays.<DataType>asList(DataTypes.INTEGER)),
                        DataTypes.INTEGER
                ),
                Arrays.<Symbol>asList(Literal.newLiteral(2))
        );

        assertThat(f1.equals(f2), is(true)); // symbols are equal

        // EqOperator doesn't know (yet) if the result of the functions will be equal so no normalization
        Function function = new Function(op.info(), Arrays.<Symbol>asList(f1, f2));
        Symbol result = op.normalizeSymbol(function);

        assertThat(result, instanceOf(Function.class));
    }
View Full Code Here

public class NotPredicateTest {

    @Test
    public void testNormalizeSymbolBoolean() throws Exception {
        NotPredicate predicate = new NotPredicate();
        Function not = new Function(predicate.info(), Arrays.<Symbol>asList(Literal.newLiteral(true)));

        assertLiteralSymbol(predicate.normalizeSymbol(not), false);
    }
View Full Code Here

        Reference name_ref = new Reference(new ReferenceInfo(
                new ReferenceIdent(new TableIdent(null, "dummy"), "foo"),
                RowGranularity.DOC, DataTypes.STRING)
        );
        Function eqName = new Function(
                new FunctionInfo(
                        new FunctionIdent(EqOperator.NAME,
                                Arrays.<DataType>asList(DataTypes.STRING, DataTypes.STRING)),
                        DataTypes.BOOLEAN
                ),
                Arrays.<Symbol>asList(name_ref, Literal.newLiteral("foo"))
        );

        Function not = new Function(notPredicate.info(), Arrays.<Symbol>asList(eqName));
        Symbol normalized = notPredicate.normalizeSymbol(not);

        assertThat(normalized, instanceOf(Function.class));
    }
View Full Code Here

public class AndOperatorTest {

    @Test
    public void testNormalizeBooleanTrueAndNonLiteral() throws Exception {
        AndOperator operator = new AndOperator();
        Function function = new Function(
                operator.info(), Arrays.<Symbol>asList(Literal.newLiteral(true), new Reference()));
        Symbol symbol = operator.normalizeSymbol(function);
        assertThat(symbol, instanceOf(Reference.class));
    }
View Full Code Here

    }

    @Test
    public void testNormalizeBooleanFalseAndNonLiteral() throws Exception {
        AndOperator operator = new AndOperator();
        Function function = new Function(
                operator.info(), Arrays.<Symbol>asList(Literal.newLiteral(false), new Reference()));
        Symbol symbol = operator.normalizeSymbol(function);

        assertLiteralSymbol(symbol, false);
    }
View Full Code Here

TOP

Related Classes of io.crate.planner.symbol.Function

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.