Search in sources :

Example 31 with FunctionIdent

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

the class PercentileAggregationTest method testReturnTypes.

@Test
public void testReturnTypes() throws Exception {
    FunctionIdent synopsis1 = new FunctionIdent(NAME, ImmutableList.<DataType>of(DataTypes.DOUBLE, DataTypes.DOUBLE));
    assertEquals(DataTypes.DOUBLE, functions.get(synopsis1).info().returnType());
    FunctionIdent synopsis2 = new FunctionIdent(NAME, ImmutableList.<DataType>of(DataTypes.DOUBLE, new ArrayType(DataTypes.DOUBLE)));
    assertEquals(new ArrayType(DataTypes.DOUBLE), functions.get(synopsis2).info().returnType());
}
Also used : ArrayType(io.crate.types.ArrayType) FunctionIdent(io.crate.metadata.FunctionIdent) Test(org.junit.Test) AggregationTest(io.crate.operation.aggregation.AggregationTest)

Example 32 with FunctionIdent

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

the class SumAggregationTest method testReturnType.

@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());
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) AggregationTest(io.crate.operation.aggregation.AggregationTest) Test(org.junit.Test)

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