Search in sources :

Example 6 with FunctionIdent

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

the class AggregationTest method normalize.

protected Symbol normalize(String functionName, Symbol... args) {
    DataType[] argTypes = new DataType[args.length];
    for (int i = 0; i < args.length; i++) {
        argTypes[i] = args[i].valueType();
    }
    AggregationFunction function = (AggregationFunction) functions.get(new FunctionIdent(functionName, Arrays.asList(argTypes)));
    return function.normalizeSymbol(new Function(function.info(), Arrays.asList(args)), new TransactionContext(SessionContext.SYSTEM_SESSION));
}
Also used : Function(io.crate.analyze.symbol.Function) FunctionIdent(io.crate.metadata.FunctionIdent) TransactionContext(io.crate.metadata.TransactionContext) DataType(io.crate.types.DataType)

Example 7 with FunctionIdent

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

the class ArbitraryAggregationTest method testReturnType.

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

Example 8 with FunctionIdent

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

the class CountAggregationTest method testReturnType.

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

Example 9 with FunctionIdent

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

the class GeometricMeanAggregationtest 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("geometric_mean", 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 10 with FunctionIdent

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

the class MaximumAggregationTest method testReturnType.

@Test
public void testReturnType() throws Exception {
    FunctionIdent fi = new FunctionIdent("max", ImmutableList.<DataType>of(DataTypes.INTEGER));
    assertEquals(DataTypes.INTEGER, 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