use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestHistogram method testSimpleHistograms.
@Test
public void testSimpleHistograms() 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", 1L, "b", 1L, "c", 1L), createStringsBlock("a", "b", "c"));
mapType = new MapType(BIGINT, BIGINT);
aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(aggregationFunction, ImmutableMap.of(100L, 1L, 200L, 1L, 300L, 1L), createLongsBlock(100L, 200L, 300L));
mapType = new MapType(DOUBLE, BIGINT);
aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE)));
assertAggregation(aggregationFunction, ImmutableMap.of(0.1, 1L, 0.3, 1L, 0.2, 1L), createDoublesBlock(0.1, 0.3, 0.2));
mapType = new MapType(BOOLEAN, BIGINT);
aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.BOOLEAN)));
assertAggregation(aggregationFunction, ImmutableMap.of(true, 1L, false, 1L), createBooleansBlock(true, false));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestHistogram method testRowHistograms.
@Test
public void testRowHistograms() throws Exception {
RowType innerRowType = new RowType(ImmutableList.of(BIGINT, DOUBLE), Optional.of(ImmutableList.of("f1", "f2")));
MapType mapType = new MapType(innerRowType, BIGINT);
InternalAggregationFunction aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), innerRowType.getTypeSignature()));
BlockBuilder builder = innerRowType.createBlockBuilder(new BlockBuilderStatus(), 3);
innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 1L, 1.0));
innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 2L, 2.0));
innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 3L, 3.0));
assertAggregation(aggregationFunction, ImmutableMap.of(ImmutableList.of(1L, 1.0), 1L, ImmutableList.of(2L, 2.0), 1L, ImmutableList.of(3L, 3.0), 1L), builder.build());
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMapAggAggregation method testDoubleArrayMap.
@Test
public void testDoubleArrayMap() throws Exception {
ArrayType arrayType = new ArrayType(VARCHAR);
MapType mapType = new MapType(DOUBLE, arrayType);
InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), arrayType.getTypeSignature()));
assertAggregation(aggFunc, ImmutableMap.of(1.0, ImmutableList.of("a", "b"), 2.0, ImmutableList.of("c", "d"), 3.0, ImmutableList.of("e", "f")), createDoublesBlock(1.0, 2.0, 3.0), createStringArraysBlock(ImmutableList.of(ImmutableList.of("a", "b"), ImmutableList.of("c", "d"), ImmutableList.of("e", "f"))));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByAggregation method testMinLongLongArray.
@Test
public void testMinLongLongArray() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("array(bigint)"), parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, ImmutableList.of(8L, 9L), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(8L, 9L), ImmutableList.of(1L, 2L), ImmutableList.of(6L, 7L), ImmutableList.of(2L, 3L))), createLongsBlock(1L, 2L, 2L, 3L));
assertAggregation(function, ImmutableList.of(2L), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(8L, 9L), ImmutableList.of(6L, 7L), ImmutableList.of(2L, 3L), ImmutableList.of(2L))), createLongsBlock(0L, 1L, 2L, -1L));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByNAggregation method testMinVarcharArray.
@Test
public void testMinVarcharArray() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("array(array(bigint))"), parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, ImmutableList.of(ImmutableList.of(2L, 3L), ImmutableList.of(4L, 5L)), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(2L, 3L), ImmutableList.of(3L, 4L), ImmutableList.of(4L, 5L))), createStringsBlock("z", "a", "x", "b"), createRLEBlock(2L, 4));
}
Aggregations