use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestChecksumAggregation method testBoolean.
@Test
public void testBoolean() throws Exception {
InternalAggregationFunction booleanAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("checksum", AGGREGATE, parseTypeSignature(VARBINARY), parseTypeSignature(BOOLEAN)));
Block block = createBooleansBlock(null, null, true, false, false);
assertAggregation(booleanAgg, expectedChecksum(BooleanType.BOOLEAN, block), block);
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestChecksumAggregation method testEmpty.
@Test
public void testEmpty() throws Exception {
InternalAggregationFunction booleanAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("checksum", AGGREGATE, parseTypeSignature(VARBINARY), parseTypeSignature(BOOLEAN)));
assertAggregation(booleanAgg, null, createBooleansBlock());
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestChecksumAggregation method testShortDecimal.
@Test
public void testShortDecimal() throws Exception {
InternalAggregationFunction decimalAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("checksum", AGGREGATE, parseTypeSignature(VARBINARY), parseTypeSignature("decimal(10,2)")));
Block block = createShortDecimalsBlock("11.11", "22.22", null, "33.33", "44.44");
DecimalType shortDecimalType = DecimalType.createDecimalType(1);
assertAggregation(decimalAgg, expectedChecksum(shortDecimalType, block), block);
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestHistogram method testDuplicateKeysValues.
@Test
public void testDuplicateKeysValues() throws Exception {
MapType mapType = new MapType(VARCHAR, BIGINT);
InternalAggregationFunction aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.VARCHAR)));
assertAggregation(aggregationFunction, ImmutableMap.of("a", 2L, "b", 1L), createStringsBlock("a", "b", "a"));
mapType = new MapType(TIMESTAMP_WITH_TIME_ZONE, BIGINT);
aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.TIMESTAMP_WITH_TIME_ZONE)));
long timestampWithTimeZone1 = packDateTimeWithZone(new DateTime(1970, 1, 1, 0, 0, 0, 0, DATE_TIME_ZONE).getMillis(), TIME_ZONE_KEY);
long timestampWithTimeZone2 = packDateTimeWithZone(new DateTime(2015, 1, 1, 0, 0, 0, 0, DATE_TIME_ZONE).getMillis(), TIME_ZONE_KEY);
assertAggregation(aggregationFunction, ImmutableMap.of(new SqlTimestampWithTimeZone(timestampWithTimeZone1), 2L, new SqlTimestampWithTimeZone(timestampWithTimeZone2), 1L), createLongsBlock(timestampWithTimeZone1, timestampWithTimeZone1, timestampWithTimeZone2));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestHistogram method testArrayHistograms.
@Test
public void testArrayHistograms() throws Exception {
ArrayType arrayType = new ArrayType(VARCHAR);
MapType mapType = new MapType(arrayType, BIGINT);
InternalAggregationFunction aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), arrayType.getTypeSignature()));
assertAggregation(aggregationFunction, ImmutableMap.of(ImmutableList.of("a", "b", "c"), 1L, ImmutableList.of("d", "e", "f"), 1L, ImmutableList.of("c", "b", "a"), 1L), createStringArraysBlock(ImmutableList.of(ImmutableList.of("a", "b", "c"), ImmutableList.of("d", "e", "f"), ImmutableList.of("c", "b", "a"))));
}
Aggregations