Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Symbol


        return info;
    }

    @Override
    public Symbol normalizeSymbol(Function symbol) {
        Symbol argument = symbol.arguments().get(0);
        if (argument.symbolType().isValueSymbol()) {
            return Literal.newLiteral(info().returnType(), evaluate((Input) argument));
        }
        return symbol;
    }
View Full Code Here


        }

        @Override
        public Symbol normalizeSymbol(Function symbol) {
            assert (symbol.arguments().size() == 2);
            Symbol base = symbol.arguments().get(0);
            Symbol value = symbol.arguments().get(1);
            if (value.symbolType().isValueSymbol() && base.symbolType().isValueSymbol()) {
                return Literal.newLiteral(info.returnType(), evaluate((Input) base, (Input) value));
            }
            return symbol;
        }
View Full Code Here

        }

        @Override
        public Symbol normalizeSymbol(Function symbol) {
            assert (symbol.arguments().size() == 1);
            Symbol value = symbol.arguments().get(0);
            if (value.symbolType().isValueSymbol()) {
                return Literal.newLiteral(info.returnType(), evaluate((Input)value));
            }
            return symbol;
        }
View Full Code Here

        final DataType arrayType = new ArrayType(DataTypes.STRING);
        ToIntArrayFunction impl = (ToIntArrayFunction)functions.get(
                new FunctionIdent(ToIntArrayFunction.NAME, ImmutableList.of(arrayType)));

        Reference foo = TestingHelpers.createReference("foo", arrayType);
        Symbol symbol = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(foo)));
        assertThat(symbol, instanceOf(Function.class));
    }
View Full Code Here

            @Override
            public DataType valueType() {
                return arrayType;
            }
        };
        Symbol normalized = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(input)));
        Object[] integers = impl.evaluate(new Input[]{input});

        assertThat(integers, is(((Input) normalized).value()));
        return integers;
    }
View Full Code Here

            @Override
            public DataType valueType() {
                return arrayType;
            }
        };
        Symbol normalized = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(input)));
        Object[] integers = impl.evaluate(new Input[]{input});

        assertThat(integers, is(((Input) normalized).value()));
        return integers;
    }
View Full Code Here

            @Override
            public DataType valueType() {
                return arrayType;
            }
        };
        Symbol normalized = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(input)));
        Object[] integers = impl.evaluate(new Input[]{input});

        assertThat(integers, is(((Input) normalized).value()));
        return integers;
    }
View Full Code Here

        );
        BytesRef[] expected = new BytesRef[]{ new BytesRef("1"), new BytesRef("2"), new BytesRef("3") };
        Function function = createFunction(ToStringArrayFunction.NAME, new ArrayType(DataTypes.STRING), arguments);
        ToStringArrayFunction arrayFunction = (ToStringArrayFunction) functions.get(function.info().ident());

        Symbol result = arrayFunction.normalizeSymbol(function);
        assertLiteralSymbol(result, expected, new ArrayType(DataTypes.STRING));

        arguments.set(0, Literal.newLiteral(new Float[]{ 1.0f, 2.0f, 3.0f }, new ArrayType(DataTypes.FLOAT)));
        expected = new BytesRef[]{ new BytesRef("1.0"), new BytesRef("2.0"), new BytesRef("3.0") };
        function = createFunction(ToStringArrayFunction.NAME, new ArrayType(DataTypes.STRING), arguments);
View Full Code Here

    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

        return analyzer.process(SqlParser.createExpression(expression), selectAnalysis);
    }

    @Test
    public void testFalseAndMatchFunction() throws Exception {
        Symbol symbol = convert(fromSQL("false and match (table_name, 'jalla')"));
        assertLiteralSymbol(symbol, false);
    }
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.