Examples of normalizeSymbol()


Examples of io.crate.metadata.FunctionImplementation.normalizeSymbol()

    public void testNormalizeSymbol() throws Exception {

        FunctionImplementation castStringToInteger = functions.get(new FunctionIdent(ToIntFunction.NAME, ImmutableList.<DataType>of(DataTypes.STRING)));

        Function function = new Function(castStringToInteger.info(), Arrays.<Symbol>asList(Literal.newLiteral("123")));
        Symbol result = castStringToInteger.normalizeSymbol(function);
        assertLiteralSymbol(result, 123);

        FunctionImplementation castFloatToInteger = functions.get(new FunctionIdent(ToIntFunction.NAME, ImmutableList.<DataType>of(DataTypes.FLOAT)));

        function = new Function(castFloatToInteger.info(), Arrays.<Symbol>asList(Literal.newLiteral(12.5f)));
View Full Code Here

Examples of io.crate.metadata.FunctionImplementation.normalizeSymbol()

    public void testNormalizeInvalidString() throws Exception {
        expectedException.expect(NumberFormatException.class);
        expectedException.expectMessage("For input string: \"hello\"");
        FunctionImplementation castStringToInteger = functions.get(new FunctionIdent(ToIntFunction.NAME, ImmutableList.<DataType>of(DataTypes.STRING)));
        Function function = new Function(castStringToInteger.info(), Arrays.<Symbol>asList(Literal.newLiteral("hello")));
        castStringToInteger.normalizeSymbol(function);
    }

    @Test
    @SuppressWarnings("unchecked")
    public void testEvaluate() throws Exception {
View Full Code Here

Examples of io.crate.metadata.FunctionImplementation.normalizeSymbol()

                Literal.newLiteral("%tY"),
                Literal.newLiteral(DataTypes.TIMESTAMP, DataTypes.TIMESTAMP.value("2014-03-02")));
        Function function = createFunction(FormatFunction.NAME, DataTypes.STRING, args);

        FunctionImplementation format = functions.get(function.info().ident());
        Symbol result = format.normalizeSymbol(function);

        assertLiteralSymbol(result, "2014");
    }

    @Test
View Full Code Here

Examples of io.crate.metadata.FunctionImplementation.normalizeSymbol()

    public void testNormalizeSymbol() throws Exception {

        FunctionImplementation castIntegerToString = functions.get(new FunctionIdent(ToStringFunction.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER)));

        Function function = new Function(castIntegerToString.info(), Arrays.<Symbol>asList(Literal.newLiteral(123)));
        Symbol result = castIntegerToString.normalizeSymbol(function);
        assertLiteralSymbol(result, "123");

        FunctionImplementation castFloatToString = functions.get(new FunctionIdent(ToStringFunction.NAME, ImmutableList.<DataType>of(DataTypes.FLOAT)));
        function = new Function(castFloatToString.info(), Arrays.<Symbol>asList(Literal.newLiteral(0.5f)));
        result = castFloatToString.normalizeSymbol(function);
View Full Code Here

Examples of io.crate.metadata.FunctionImplementation.normalizeSymbol()

        Symbol result = castIntegerToString.normalizeSymbol(function);
        assertLiteralSymbol(result, "123");

        FunctionImplementation castFloatToString = functions.get(new FunctionIdent(ToStringFunction.NAME, ImmutableList.<DataType>of(DataTypes.FLOAT)));
        function = new Function(castFloatToString.info(), Arrays.<Symbol>asList(Literal.newLiteral(0.5f)));
        result = castFloatToString.normalizeSymbol(function);
        assertLiteralSymbol(result, "0.5");

        FunctionImplementation castStringToString = functions.get(new FunctionIdent(ToStringFunction.NAME, ImmutableList.<DataType>of(DataTypes.STRING)));
        function = new Function(castStringToString.info(), Arrays.<Symbol>asList(Literal.newLiteral("hello")));
        result = castStringToString.normalizeSymbol(function);
View Full Code Here

Examples of io.crate.metadata.FunctionImplementation.normalizeSymbol()

        result = castFloatToString.normalizeSymbol(function);
        assertLiteralSymbol(result, "0.5");

        FunctionImplementation castStringToString = functions.get(new FunctionIdent(ToStringFunction.NAME, ImmutableList.<DataType>of(DataTypes.STRING)));
        function = new Function(castStringToString.info(), Arrays.<Symbol>asList(Literal.newLiteral("hello")));
        result = castStringToString.normalizeSymbol(function);
        assertLiteralSymbol(result, "hello");
    }

    @Test
    public void testInvalidType() throws Exception {
View Full Code Here

Examples of io.crate.metadata.FunctionImplementation.normalizeSymbol()

    @SuppressWarnings("unchecked")
    private Symbol normalizeFunctionSymbol(Function function) {
        FunctionImplementation impl = functions.get(function.info().ident());
        if (impl != null) {
            return impl.normalizeSymbol(function);
        }
        if (logger.isTraceEnabled()) {
            logger.trace(SymbolFormatter.format("No implementation found for function %s", function));
        }
        return function;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.