Package io.crate.metadata

Examples of io.crate.metadata.FunctionIdent


        return executeAggregation("collect_set", dataType, data);
    }

    @Test
    public void testReturnType() throws Exception {
        FunctionIdent fi = new FunctionIdent("collect_set", ImmutableList.<DataType>of(DataTypes.INTEGER));
        assertEquals(DataTypes.INTEGER, functions.get(fi).info().returnType());
    }
View Full Code Here


        assertTrue(((Set)result[0][0]).contains(0.7d));
    }

    @Test
    public void testLongSerialization() throws Exception {
        FunctionIdent fi = new FunctionIdent("collect_set", ImmutableList.<DataType>of(DataTypes.LONG));
        AggregationFunction impl = (AggregationFunction) functions.get(fi);
        AggregationState state = impl.newState();

        BytesStreamOutput streamOutput = new BytesStreamOutput();
        state.writeTo(streamOutput);
View Full Code Here

        return executeAggregation("arbitrary", dataType, data);
    }

    @Test
    public void testReturnType() throws Exception {
        FunctionIdent fi = new FunctionIdent("arbitrary", ImmutableList.<DataType>of(DataTypes.INTEGER));
        assertEquals(DataTypes.INTEGER, functions.get(fi).info().returnType());
    }
View Full Code Here

        return executeAggregation("sum", dataType, data);
    }

    @Test
    public void testReturnType() throws Exception {
        FunctionIdent fi = new FunctionIdent("sum", ImmutableList.<DataType>of(DataTypes.INTEGER));
        // Return type is fixed to Double
        assertEquals(DataTypes.DOUBLE, functions.get(fi).info().returnType());
    }
View Full Code Here

        return executeAggregation("count", dataType, data);
    }

    @Test
    public void testReturnType() throws Exception {
        FunctionIdent fi = new FunctionIdent("count", ImmutableList.<DataType>of(DataTypes.INTEGER));
        // Return type is fixed to Long
        assertEquals(DataTypes.LONG, functions.get(fi).info().returnType());
    }
View Full Code Here

                DataTypes.FLOAT,
                DataTypes.DOUBLE,
                DataTypes.STRING
                );
        for (DataType dataType : supportedTypes) {
            FunctionIdent ident = new FunctionIdent(functionName, Arrays.asList(dataType));
            FunctionImplementation implementation = functions.get(ident);
            assertThat(implementation, instanceOf(ToTimestampFunction.class));
            assertEquals(((ToTimestampFunction) implementation).returnType, DataTypes.TIMESTAMP);
        }
    }
View Full Code Here

                DataTypes.OBJECT,
                DataTypes.BOOLEAN
        );
        for (DataType dataType : unsupportedTypes) {
            try {
                FunctionIdent ident = new FunctionIdent(functionName, Arrays.asList(dataType));
                functions.get(ident);
            } catch (Exception e) {
                assertEquals(e.getMessage(), String.format("type '%s' not supported for conversion", dataType.getName()));
            }
        }
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    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);
        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");
    }
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(ToStringFunction.NAME, ImmutableList.<DataType>of(DataTypes.OBJECT)));
    }
View Full Code Here

    }

    @Test
    @SuppressWarnings("unchecked")
    public void testEvaluate() throws Exception {
        FunctionIdent ident = new FunctionIdent(ToStringFunction.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER));
        Scalar<Object, Object> format = (Scalar<Object, Object>) functions.get(ident);
        Input<Object> arg1 = new Input<Object>() {
            @Override
            public Object value() {
                return 123;
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.