Search in sources :

Example 26 with FunctionIdent

use of io.crate.metadata.FunctionIdent in project crate by crate.

the class VarianceAggregationTest method testReturnType.

@Test
public void testReturnType() throws Exception {
    for (DataType<?> type : Iterables.concat(DataTypes.NUMERIC_PRIMITIVE_TYPES, Arrays.asList(DataTypes.TIMESTAMP))) {
        FunctionIdent fi = new FunctionIdent("variance", ImmutableList.<DataType>of(type));
        // Return type is fixed to Double
        assertEquals(DataTypes.DOUBLE, functions.get(fi).info().returnType());
    }
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) AggregationTest(io.crate.operation.aggregation.AggregationTest) Test(org.junit.Test)

Example 27 with FunctionIdent

use of io.crate.metadata.FunctionIdent in project crate by crate.

the class AggregatorTest method setUpFunctions.

@Before
public void setUpFunctions() {
    Functions functions = getFunctions();
    FunctionIdent countAggIdent = new FunctionIdent(CountAggregation.NAME, Arrays.<DataType>asList(DataTypes.STRING));
    countImpl = (AggregationFunction) functions.get(countAggIdent);
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) TestingHelpers.getFunctions(io.crate.testing.TestingHelpers.getFunctions) Functions(io.crate.metadata.Functions) Before(org.junit.Before)

Example 28 with FunctionIdent

use of io.crate.metadata.FunctionIdent in project crate by crate.

the class AverageAggregationTest method testReturnType.

@Test
public void testReturnType() throws Exception {
    FunctionIdent fi = new FunctionIdent("avg", ImmutableList.<DataType>of(DataTypes.INTEGER));
    // Return type is fixed to Double
    assertEquals(DataTypes.DOUBLE, functions.get(fi).info().returnType());
    FunctionIdent meanFi = new FunctionIdent("mean", ImmutableList.<DataType>of(DataTypes.INTEGER));
    assertEquals(DataTypes.DOUBLE, functions.get(meanFi).info().returnType());
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) AggregationTest(io.crate.operation.aggregation.AggregationTest) Test(org.junit.Test)

Example 29 with FunctionIdent

use of io.crate.metadata.FunctionIdent in project crate by crate.

the class CollectSetAggregationTest method testLongSerialization.

@Test
public void testLongSerialization() throws Exception {
    FunctionIdent fi = new FunctionIdent("collect_set", ImmutableList.<DataType>of(DataTypes.LONG));
    AggregationFunction impl = (AggregationFunction) functions.get(fi);
    Object state = impl.newState(ramAccountingContext);
    BytesStreamOutput streamOutput = new BytesStreamOutput();
    impl.partialType().streamer().writeValueTo(streamOutput, state);
    Object newState = impl.partialType().streamer().readValueFrom(StreamInput.wrap(streamOutput.bytes()));
    assertEquals(state, newState);
}
Also used : AggregationFunction(io.crate.operation.aggregation.AggregationFunction) FunctionIdent(io.crate.metadata.FunctionIdent) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) AggregationTest(io.crate.operation.aggregation.AggregationTest)

Example 30 with FunctionIdent

use of io.crate.metadata.FunctionIdent in project crate by crate.

the class CollectSetAggregationTest method testReturnType.

@Test
public void testReturnType() throws Exception {
    FunctionIdent fi = new FunctionIdent("collect_set", ImmutableList.<DataType>of(DataTypes.INTEGER));
    assertEquals(new SetType(DataTypes.INTEGER), functions.get(fi).info().returnType());
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) SetType(io.crate.types.SetType) Test(org.junit.Test) AggregationTest(io.crate.operation.aggregation.AggregationTest)

Aggregations

FunctionIdent (io.crate.metadata.FunctionIdent)32 Test (org.junit.Test)19 FunctionInfo (io.crate.metadata.FunctionInfo)15 AggregationTest (io.crate.operation.aggregation.AggregationTest)12 DataType (io.crate.types.DataType)8 CrateUnitTest (io.crate.test.integration.CrateUnitTest)6 Aggregation (io.crate.analyze.symbol.Aggregation)4 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)4 AggregationFunction (io.crate.operation.aggregation.AggregationFunction)3 InputCollectExpression (io.crate.operation.collect.InputCollectExpression)3 StreamInput (org.elasticsearch.common.io.stream.StreamInput)3 Function (io.crate.analyze.symbol.Function)2 InputColumn (io.crate.analyze.symbol.InputColumn)2 Symbol (io.crate.analyze.symbol.Symbol)2 Reference (io.crate.metadata.Reference)2 Aggregator (io.crate.operation.aggregation.Aggregator)2 CountAggregation (io.crate.operation.aggregation.impl.CountAggregation)2 CollectExpression (io.crate.operation.collect.CollectExpression)2 SetType (io.crate.types.SetType)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1