Package io.crate.metadata

Examples of io.crate.metadata.FunctionIdent


    }


    public Object[][] executeAggregation(String name, DataType dataType, Object[][] data) throws Exception {

        FunctionIdent fi;
        InputCollectExpression[] inputs;
        if (dataType != null) {
            fi = new FunctionIdent(name, ImmutableList.of(dataType));
            inputs = new InputCollectExpression[]{new InputCollectExpression(0)};
        } else {
            fi = new FunctionIdent(name, ImmutableList.<DataType>of());
            inputs = new InputCollectExpression[0];
        }
        AggregationFunction impl = (AggregationFunction) functions.get(fi);
        AggregationState state = impl.newState();
View Full Code Here


    @Test
    public void testInvalidType() throws Exception {
        expectedException.expect(IllegalArgumentException.class);
        expectedException.expectMessage("type 'object' not supported for conversion");
        functions.get(new FunctionIdent(functionName, ImmutableList.<DataType>of(DataTypes.OBJECT)));
    }
View Full Code Here

    @Before
    public void setUpFunctions() {
        Injector injector = new ModulesBuilder().add(new AggregationImplModule()).createInjector();
        Functions functions = injector.getInstance(Functions.class);
        countAggIdent = new FunctionIdent(CountAggregation.NAME, Arrays.<DataType>asList(DataTypes.STRING));
        countImpl = (AggregationFunction) functions.get(countAggIdent);
    }
View Full Code Here

                .add(new ScalarFunctionModule()).createInjector().getInstance(Functions.class);
    }


    private ToFloatFunction getFunction(DataType type) {
        return (ToFloatFunction) functions.get(new FunctionIdent(functionName, Arrays.asList(type)));
    }
View Full Code Here

    @Test
    public void testInvalidType() throws Exception {
        expectedException.expect(IllegalArgumentException.class);
        expectedException.expectMessage("type 'object' not supported for conversion");
        functions.get(new FunctionIdent(functionName, ImmutableList.<DataType>of(DataTypes.OBJECT)));
    }
View Full Code Here

    @Test
    public void testInvalidArgumentType() throws Exception {
        expectedException.expect(IllegalArgumentException.class);
        expectedException.expectMessage("Argument must be a collection type");
        functions.get(new FunctionIdent(ToStringArrayFunction.NAME, ImmutableList.<DataType>of(DataTypes.STRING)));
    }
View Full Code Here

    @Test
    public void testInvalidArgumentInnerType() throws Exception {
        expectedException.expect(IllegalArgumentException.class);
        expectedException.expectMessage("Array inner type 'object' not supported for conversion");
        functions.get(new FunctionIdent(ToStringArrayFunction.NAME, ImmutableList.<DataType>of(new ArrayType(DataTypes.OBJECT))));
    }
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    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)));
        result = castStringToInteger.normalizeSymbol(function);
        assertLiteralSymbol(result, 12);
    }
View Full Code Here

    @Test
    public void testInvalidType() throws Exception {
        expectedException.expect(IllegalArgumentException.class);
        expectedException.expectMessage("type 'object' not supported for conversion");
        functions.get(new FunctionIdent(ToIntFunction.NAME, ImmutableList.<DataType>of(DataTypes.OBJECT)));
    }
View Full Code Here

    @Test
    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);
    }
View Full Code Here

TOP

Related Classes of io.crate.metadata.FunctionIdent

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.