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());
}
}
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);
}
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());
}
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);
}
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());
}
Aggregations