Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Function


        return getFunction(type).evaluate(input);
    }

    private Symbol normalize(Object value, DataType type) {
        ToNullFunction function = getFunction(type);
        return function.normalizeSymbol(new Function(function.info(),
                Arrays.<Symbol>asList(Literal.newLiteral(type, value))));
    }
View Full Code Here


import static org.hamcrest.Matchers.nullValue;

public class RegexpMatchOperatortest {
    private static Symbol normalizeSymbol(String source, String pattern) {
        RegexpMatchOperator op = new RegexpMatchOperator();
        Function function = new Function(
                op.info(),
                Arrays.<Symbol>asList(Literal.newLiteral(source), Literal.newLiteral(pattern))
        );
        return op.normalizeSymbol(function);
    }
View Full Code Here

            return o;
        }
    }

    public Symbol normalize(Symbol interval, Symbol timestamp) {
        Function function = new Function(func.info(), Arrays.asList(interval, timestamp));
        return func.normalizeSymbol(function);
    }
View Full Code Here

    public void testDateTruncWithLongLiteral() {
        Scalar implementation = (Scalar)functions.get(new FunctionIdent(DateTruncFunction.NAME,
                Arrays.<DataType>asList(DataTypes.STRING, DataTypes.LONG)));
        assertNotNull(implementation);

        Function function = new Function(implementation.info(), Arrays.<Symbol>asList(
                Literal.newLiteral("day"),
                Literal.newLiteral(1401777485000L)
        ));
        Literal day = (Literal)implementation.normalizeSymbol(function);
        assertThat((Long)day.value(), is(1401753600000L));
View Full Code Here

    public void testDateTruncWithStringLiteral() {
        Scalar implementation = (Scalar)functions.get(new FunctionIdent(DateTruncFunction.NAME,
                Arrays.<DataType>asList(DataTypes.STRING, DataTypes.STRING)));
        assertNotNull(implementation);

        Function function = new Function(implementation.info(), Arrays.<Symbol>asList(
                Literal.newLiteral("day"),
                Literal.newLiteral("2014-06-03")
        ));
        Literal day = (Literal)implementation.normalizeSymbol(function);
        assertThat((Long)day.value(), is(1401753600000L));
View Full Code Here

    @SuppressWarnings("unchecked")
    public void testDateTruncWithStringReference() {
        Scalar implementation = (Scalar)functions.get(new FunctionIdent(DateTruncFunction.NAME,
                Arrays.<DataType>asList(DataTypes.STRING, DataTypes.STRING)));
        assertNotNull(implementation);
        Function function = new Function(implementation.info(), Arrays.<Symbol>asList(
                Literal.newLiteral("day"),
                createReference("dummy", DataTypes.STRING)
        ));
        implementation.normalizeSymbol(function);
    }
View Full Code Here

        normalize(Literal.newLiteral("unknown interval"), Literal.newLiteral(""));
    }

    @Test
    public void testNormalizeSymbolReferenceTimestamp() throws Exception {
        Function function = new Function(func.info(),
                Arrays.<Symbol>asList(Literal.newLiteral("day"), new Reference(new ReferenceInfo(null,null, DataTypes.TIMESTAMP))));
        Symbol result = func.normalizeSymbol(function);
        assertSame(function, result);
    }
View Full Code Here

    private static Symbol normalizeSymbol(String expression, String pattern) {
        LikeOperator op = new LikeOperator(
                LikeOperator.generateInfo(LikeOperator.NAME, DataTypes.STRING)
        );
        Function function = new Function(
                op.info(),
                Arrays.<Symbol>asList(Literal.newLiteral(expression), Literal.newLiteral(pattern))
        );
        return op.normalizeSymbol(function);
    }
View Full Code Here

        List<Symbol> arguments = Arrays.<Symbol>asList(
                createReference("names", term.valueType()),
                termIndex
        );
        Function function = createFunction(SubscriptFunction.NAME, DataTypes.STRING, arguments);
        SubscriptFunction subscriptFunction = (SubscriptFunction) functions.get(function.info().ident());

        Input[] args = new Input[2];
        args[0] = new Input<Object>() {
            @Override
            public Object value() {
View Full Code Here

        final BytesRef expected = new BytesRef("Youri");
        List<Symbol> arguments = Arrays.<Symbol>asList(
                term,
                termIndex
        );
        Function function = createFunction(SubscriptFunction.NAME, DataTypes.STRING, arguments);
        SubscriptFunction subscriptFunction = (SubscriptFunction) functions.get(function.info().ident());

        Symbol result = subscriptFunction.normalizeSymbol(function);
        assertLiteralSymbol(result, expected.utf8ToString());

        arguments = Arrays.<Symbol>asList(
                createReference("text", term.valueType()),
                termIndex
        );
        function = createFunction(SubscriptFunction.NAME, DataTypes.STRING, arguments);
        subscriptFunction = (SubscriptFunction) functions.get(function.info().ident());

        result = subscriptFunction.normalizeSymbol(function);
        assertThat(result, instanceOf(Function.class));
        assertThat((Function)result, is(function));
    }
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.