use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestHistogram method testWithNulls.
@Test
public void testWithNulls() throws Exception {
MapType mapType = new MapType(BIGINT, BIGINT);
InternalAggregationFunction aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(aggregationFunction, ImmutableMap.of(1L, 1L, 2L, 1L), createLongsBlock(2L, null, 1L));
mapType = new MapType(BIGINT, BIGINT);
aggregationFunction = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(aggregationFunction, null, createLongsBlock((Long) null));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestHistogram method testLargerHistograms.
@Test
public void testLargerHistograms() 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", 25L, "b", 10L, "c", 12L, "d", 1L, "e", 2L), createStringsBlock("a", "b", "c", "d", "e", "e", "c", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "c", "c", "b", "a", "c", "c", "b", "a", "c", "c", "b", "a", "c", "c", "b", "a", "c", "c"));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMapAggAggregation method testDuplicateKeysValues.
@Test
public void testDuplicateKeysValues() throws Exception {
MapType mapType = new MapType(DOUBLE, VARCHAR);
InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR)));
assertAggregation(aggFunc, ImmutableMap.of(1.0, "a"), createDoublesBlock(1.0, 1.0, 1.0), createStringsBlock("a", "b", "c"));
mapType = new MapType(DOUBLE, INTEGER);
aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.INTEGER)));
assertAggregation(aggFunc, ImmutableMap.of(1.0, 99, 2.0, 99, 3.0, 99), createDoublesBlock(1.0, 2.0, 3.0), createTypedLongsBlock(INTEGER, ImmutableList.of(99L, 99L, 99L)));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMapAggAggregation method testDoubleRowMap.
@Test
public void testDoubleRowMap() throws Exception {
RowType innerRowType = new RowType(ImmutableList.of(INTEGER, DOUBLE), Optional.of(ImmutableList.of("f1", "f2")));
MapType mapType = new MapType(DOUBLE, innerRowType);
InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), innerRowType.getTypeSignature()));
BlockBuilder builder = innerRowType.createBlockBuilder(new BlockBuilderStatus(), 3);
innerRowType.writeObject(builder, toRow(ImmutableList.of(INTEGER, DOUBLE), 1L, 1.0));
innerRowType.writeObject(builder, toRow(ImmutableList.of(INTEGER, DOUBLE), 2L, 2.0));
innerRowType.writeObject(builder, toRow(ImmutableList.of(INTEGER, DOUBLE), 3L, 3.0));
assertAggregation(aggFunc, ImmutableMap.of(1.0, ImmutableList.of(1, 1.0), 2.0, ImmutableList.of(2, 2.0), 3.0, ImmutableList.of(3, 3.0)), createDoublesBlock(1.0, 2.0, 3.0), builder.build());
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMapAggAggregation method testSimpleMaps.
@Test
public void testSimpleMaps() throws Exception {
MapType mapType = new MapType(DOUBLE, VARCHAR);
InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR)));
assertAggregation(aggFunc, ImmutableMap.of(1.0, "a", 2.0, "b", 3.0, "c"), createDoublesBlock(1.0, 2.0, 3.0), createStringsBlock("a", "b", "c"));
mapType = new MapType(DOUBLE, INTEGER);
aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.INTEGER)));
assertAggregation(aggFunc, ImmutableMap.of(1.0, 3, 2.0, 2, 3.0, 1), createDoublesBlock(1.0, 2.0, 3.0), createTypedLongsBlock(INTEGER, ImmutableList.of(3L, 2L, 1L)));
mapType = new MapType(DOUBLE, BOOLEAN);
aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.BOOLEAN)));
assertAggregation(aggFunc, ImmutableMap.of(1.0, true, 2.0, false, 3.0, false), createDoublesBlock(1.0, 2.0, 3.0), createBooleansBlock(true, false, false));
}
Aggregations