Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Function


        assertLiteralSymbol(result, "");
    }

    @Test
    public void testNullLiteralFrom() throws Exception {
        Function function = substr("cratedata", Literal.NULL);
        Symbol result = funcA.normalizeSymbol(function);
        assertLiteralSymbol(result, null, DataTypes.UNDEFINED);
    }
View Full Code Here


        assertLiteralSymbol(result, null, DataTypes.UNDEFINED);
    }

    @Test
    public void testNullLiteralCount() throws Exception {
        Function function = substr("cratedata", Literal.newLiteral(1), Literal.NULL);
        Symbol result = funcB.normalizeSymbol(function);
        assertLiteralSymbol(result, null, DataTypes.UNDEFINED);
    }
View Full Code Here

        assertLiteralSymbol(result, null, DataTypes.UNDEFINED);
    }

    @Test
    public void testNullLiteralFromCount() throws Exception {
        Function function = substr("cratedata", Literal.NULL, Literal.NULL);
        Symbol result = funcB.normalizeSymbol(function);
        assertLiteralSymbol(result, null, DataTypes.UNDEFINED);
    }
View Full Code Here

        List<Symbol> args = Arrays.<Symbol>asList(
                createReference("tag", DataTypes.STRING),
                startPos
        );
        Function function = createFunction(SubstrFunction.NAME, DataTypes.STRING, args);
        Scalar<BytesRef, Object> format = (Scalar<BytesRef, Object>) functions.get(function.info().ident());

        Input<Object> arg1 = new Input<Object>() {
            @Override
            public Object value() {
                return new BytesRef("cratedata");
            }
        };
        Input<Object> arg2 = new Input<Object>() {
            @Override
            public Object value() {
                return startPos.value();
            }
        };

        BytesRef result = format.evaluate(arg1, arg2);
        assertThat(result.utf8ToString(), is("data"));

        final Literal<Long> count = Literal.newLiteral(2L);

        args = Arrays.<Symbol>asList(
                createReference("tag", DataTypes.STRING),
                startPos,
                count
        );
        function = createFunction(SubstrFunction.NAME, DataTypes.STRING, args);
        format = (Scalar<BytesRef, Object>) functions.get(function.info().ident());

        Input<Object> arg3 = new Input<Object>() {
            @Override
            public Object value() {
                return count.value();
View Full Code Here

        List<Symbol> arguments = Arrays.<Symbol>asList(
                Literal.newLiteral("foobarbequebaz bar"),
                Literal.newLiteral("(ba)"),
                Literal.newLiteral("Crate")
        );
        Function function = createFunction(ReplaceFunction.NAME, DataTypes.STRING, arguments);
        ReplaceFunction regexpImpl = (ReplaceFunction) functions.get(function.info().ident());

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

        arguments = Arrays.<Symbol>asList(
                createReference("text", DataTypes.STRING),
                Literal.newLiteral("(ba)"),
                Literal.newLiteral("Crate")
        );
        function = createFunction(ReplaceFunction.NAME, DataTypes.STRING, arguments);
        regexpImpl = (ReplaceFunction) functions.get(function.info().ident());

        result = regexpImpl.normalizeSymbol(function);
        assertThat(result, instanceOf(Function.class));
        assertThat((Function)result, is(function));
    }
View Full Code Here

        List<Symbol> args = Arrays.<Symbol>asList(
                createReference("tag", DataTypes.STRING),
                createReference("start", DataTypes.LONG),
                createReference("end", DataTypes.LONG)
        );
        Function function = createFunction(SubstrFunction.NAME, DataTypes.STRING, args);
        Scalar<BytesRef, Object> format = (Scalar<BytesRef, Object>) functions.get(function.info().ident());

        Input<Object> arg1 = new Input<Object>() {
            @Override
            public Object value() {
                return new BytesRef("cratedata");
View Full Code Here

        List<Symbol> args = Arrays.<Symbol>asList(
                createReference("tag", DataTypes.STRING),
                createReference("start", DataTypes.INTEGER),
                createReference("end", DataTypes.SHORT)
        );
        Function function = createFunction(SubstrFunction.NAME, DataTypes.STRING, args);
        Scalar<BytesRef, Object> format = (Scalar<BytesRef, Object>) functions.get(function.info().ident());

        BytesRef resultBytesRef = format.evaluate(generateInputs(new BytesRef("cratedata"), 1, 5));
        assertThat(resultBytesRef.utf8ToString(), is("crate"));

        BytesRef resultString = format.evaluate(generateInputs("cratedata", 1, 5));
View Full Code Here

        List<Symbol> args = Arrays.<Symbol>asList(
                createReference("tag", DataTypes.STRING),
                createReference("start", DataTypes.INTEGER),
                createReference("end", DataTypes.SHORT)
        );
        Function function = createFunction(SubstrFunction.NAME, DataTypes.STRING, args);
        Scalar<BytesRef, Object> format = (Scalar<BytesRef, Object>) functions.get(function.info().ident());

        assertNull(format.evaluate(
                (Input) Literal.newLiteral(DataTypes.STRING, null),
                (Input) Literal.newLiteral(1)));
    }
View Full Code Here

                Literal.newLiteral("foobarbequebaz bar"),
                Literal.newLiteral("(ba)"),
                Literal.newLiteral("Crate"),
                Literal.newLiteral("us n")
        );
        Function function = createFunction(ReplaceFunction.NAME, DataTypes.STRING, arguments);
        ReplaceFunction regexpImpl = (ReplaceFunction) functions.get(function.info().ident());

        Symbol result = regexpImpl.normalizeSymbol(function);
        assertLiteralSymbol(result, expected.utf8ToString());
    }
View Full Code Here

                (Input) Literal.newLiteral(1)));
    }

    @Test
    public void testNormalizeWithNullLiteral() throws Exception {
        Function function = createFunction(SubstrFunction.NAME, DataTypes.STRING,
                Arrays.<Symbol>asList(
                        Literal.newLiteral(DataTypes.STRING, null),
                        Literal.newLiteral(1)
                ));
        Scalar<BytesRef, Object> func = (Scalar<BytesRef, Object>) functions.get(function.info().ident());
        Symbol symbol = func.normalizeSymbol(function);
        assertNull(((Literal) symbol).value());
    }
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.