Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Symbol


        assertLiteralSymbol(normalized, true);
    }

    @Test
    public void testNormalizeWithTwoStringLiterals() throws Exception {
        Symbol normalized = normalize(
                Literal.newLiteral("POINT (10 10)"),
                Literal.newLiteral("POLYGON ((5 5, 20 5, 30 30, 5 30, 5 5))"));
        assertLiteralSymbol(normalized, true);
    }
View Full Code Here


        assertLiteralSymbol(normalized, true);
    }

    @Test
    public void testNormalizeWithStringLiteralAndReference() throws Exception {
        Symbol normalized = normalize(
                createReference("point", DataTypes.GEO_POINT),
                Literal.newLiteral("POLYGON ((5 5, 20 5, 30 30, 5 30, 5 5))"));
        assertThat(normalized, Matchers.instanceOf(Function.class));
        Function function = (Function) normalized;
        Symbol symbol = function.arguments().get(1);
        assertThat(DataTypeVisitor.fromSymbol(symbol), equalTo((DataType) DataTypes.GEO_SHAPE));
    }
View Full Code Here

    @Override
    public Symbol normalizeSymbol(Function function) {
        assert (function.arguments().size() > 1);

        Symbol formatString = function.arguments().get(0);
        if (formatString.symbolType() != SymbolType.LITERAL
                && !((Literal)formatString).valueType().equals(DataTypes.STRING)) {
            // probably something like   format(column_with_format_string, arg1) ?
            return function;
        }
View Full Code Here

        if (anyNonLiterals(symbol.arguments())) {
            return symbol;
        }

        final Symbol input = symbol.arguments().get(0);
        final Symbol index = symbol.arguments().get(1);
        final Object inputValue = ((Input) input).value();
        final Object indexValue = ((Input) index).value();
        if (inputValue == null || indexValue == null) {
            return Literal.NULL;
        }
View Full Code Here

    @Override
    public Symbol normalizeSymbol(Function symbol) {
        final int size = symbol.arguments().size();
        assert (size >= 2 && size <= 3);

        final Symbol input = symbol.arguments().get(0);
        final Symbol beginIdx = symbol.arguments().get(1);

        if (anyNonLiterals(input, beginIdx, symbol.arguments())) {
            return symbol;
        }
View Full Code Here

                sourceLatitude, sourceLongitude, targetLatitude, targetLongitude, DistanceUnit.METERS);
    }

    @Override
    public Symbol normalizeSymbol(Function symbol) {
        Symbol arg1 = symbol.arguments().get(0);
        Symbol arg2 = symbol.arguments().get(1);
        DataType arg1Type = DataTypeVisitor.fromSymbol(arg1);
        DataType arg2Type = DataTypeVisitor.fromSymbol(arg2);

        boolean arg1IsReference = true;
        boolean literalConverted = false;
        short numLiterals = 0;

        if (arg1.symbolType().isValueSymbol()) {
            numLiterals++;
            arg1IsReference = false;
            if (!arg1Type.equals(DataTypes.GEO_POINT)) {
                literalConverted = true;
                arg1 = Literal.toLiteral(arg1, DataTypes.GEO_POINT);
            }
        } else {
            validateType(arg1, arg1Type);
        }

        if (arg2.symbolType().isValueSymbol()) {
            numLiterals++;
            if (!arg2Type.equals(DataTypes.GEO_POINT)) {
                literalConverted = true;
                arg2 = Literal.toLiteral(arg2, DataTypes.GEO_POINT);
            }
View Full Code Here

        return info;
    }

    @Override
    public Symbol normalizeSymbol(Function symbol) {
        Symbol left = symbol.arguments().get(0);
        Symbol right = symbol.arguments().get(1);
        DataType leftType = DataTypeVisitor.fromSymbol(left);
        DataType rightType = DataTypeVisitor.fromSymbol(right);

        boolean literalConverted = false;
        short numLiterals = 0;

        if (left.symbolType().isValueSymbol()) {
            numLiterals++;
            if (leftType.equals(DataTypes.STRING)) {
                left = Literal.toLiteral(left, DataTypes.GEO_SHAPE);
                literalConverted = true;
            }
        } else {
            ensureShapeOrPoint(leftType);
        }

        if (right.symbolType().isValueSymbol()) {
            numLiterals++;
            if (rightType.equals(DataTypes.STRING)) {
                right = Literal.toLiteral(right, DataTypes.GEO_SHAPE);
                literalConverted = true;
            }
View Full Code Here

    @Override
    protected DataType[] visitSelectAnalysis(SelectAnalysis analysis, Void context) {
        DataType[] types = new DataType[analysis.outputSymbols().size()];
        java.util.List<Symbol> outputSymbols = analysis.outputSymbols();
        Symbol symbol;
        for (int i = 0, outputSymbolsSize = outputSymbols.size(); i < outputSymbolsSize; i++) {
            symbol = outputSymbols.get(i);
            assert symbol instanceof DataTypeSymbol;
            types[i] = ((DataTypeSymbol) symbol).valueType();
        }
View Full Code Here

        if (anyNonLiterals(symbol.arguments())) {
            return symbol;
        }

        final Symbol input = symbol.arguments().get(0);
        final Symbol pattern = symbol.arguments().get(1);
        final Object inputValue = ((Input) input).value();
        final Object patternValue = ((Input) pattern).value();
        if (inputValue == null || patternValue == null) {
            return Literal.NULL;
        }
View Full Code Here

        if (anyNonLiterals(symbol.arguments())) {
            return symbol;
        }

        final Symbol input = symbol.arguments().get(0);
        final Symbol pattern = symbol.arguments().get(1);
        final Symbol replacement = symbol.arguments().get(2);
        final Object inputValue = ((Input) input).value();
        final Object patternValue = ((Input) pattern).value();
        final Object replacementValue = ((Input) replacement).value();
        if (inputValue == null || patternValue == null || replacement == null) {
            return Literal.NULL;
View Full Code Here

TOP

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

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.