use of com.facebook.presto.type.ArrayType in project presto by prestodb.
the class TestChecksumAggregation method testArray.
@Test
public void testArray() throws Exception {
ArrayType arrayType = new ArrayType(BigintType.BIGINT);
InternalAggregationFunction stringAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("checksum", AGGREGATE, VarbinaryType.VARBINARY.getTypeSignature(), arrayType.getTypeSignature()));
Block block = createArrayBigintBlock(asList(null, asList(1L, 2L), asList(3L, 4L), asList(5L, 6L)));
assertAggregation(stringAgg, expectedChecksum(arrayType, block), block);
}
use of com.facebook.presto.type.ArrayType 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"))));
}
use of com.facebook.presto.type.ArrayType 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.type.ArrayType in project presto by prestodb.
the class TestMultimapAggAggregation method testDoubleArrayMultimap.
@Test
public void testDoubleArrayMultimap() throws Exception {
Type arrayType = new ArrayType(VARCHAR);
List<Double> expectedKeys = ImmutableList.of(1.0, 2.0, 3.0);
List<List<String>> expectedValues = ImmutableList.of(ImmutableList.of("a", "b"), ImmutableList.of("c"), ImmutableList.of("d", "e", "f"));
testMultimapAgg(DOUBLE, expectedKeys, arrayType, expectedValues);
}
use of com.facebook.presto.type.ArrayType in project presto by prestodb.
the class TestMapUnionAggregation method testStructural.
@Test
public void testStructural() throws Exception {
MapType mapType = new MapType(DOUBLE, new ArrayType(VARCHAR));
InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
assertAggregation(aggFunc, ImmutableMap.of(1.0, ImmutableList.of("a", "b"), 2.0, ImmutableList.of("c", "d"), 3.0, ImmutableList.of("e", "f"), 4.0, ImmutableList.of("r", "s")), arrayBlockOf(mapType, mapBlockOf(DOUBLE, new ArrayType(VARCHAR), ImmutableMap.of(1.0, ImmutableList.of("a", "b"), 2.0, ImmutableList.of("c", "d"), 3.0, ImmutableList.of("e", "f"))), mapBlockOf(DOUBLE, new ArrayType(VARCHAR), ImmutableMap.of(1.0, ImmutableList.of("x", "y"), 4.0, ImmutableList.of("r", "s"), 3.0, ImmutableList.of("w", "z")))));
mapType = new MapType(DOUBLE, new MapType(VARCHAR, VARCHAR));
aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
assertAggregation(aggFunc, ImmutableMap.of(1.0, ImmutableMap.of("a", "b"), 2.0, ImmutableMap.of("c", "d"), 3.0, ImmutableMap.of("e", "f")), arrayBlockOf(mapType, mapBlockOf(DOUBLE, new MapType(VARCHAR, VARCHAR), ImmutableMap.of(1.0, ImmutableMap.of("a", "b"), 2.0, ImmutableMap.of("c", "d"))), mapBlockOf(DOUBLE, new MapType(VARCHAR, VARCHAR), ImmutableMap.of(3.0, ImmutableMap.of("e", "f")))));
mapType = new MapType(new ArrayType(VARCHAR), DOUBLE);
aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
assertAggregation(aggFunc, ImmutableMap.of(ImmutableList.of("a", "b"), 1.0, ImmutableList.of("c", "d"), 2.0, ImmutableList.of("e", "f"), 3.0), arrayBlockOf(mapType, mapBlockOf(new ArrayType(VARCHAR), DOUBLE, ImmutableMap.of(ImmutableList.of("a", "b"), 1.0, ImmutableList.of("e", "f"), 3.0)), mapBlockOf(new ArrayType(VARCHAR), DOUBLE, ImmutableMap.of(ImmutableList.of("c", "d"), 2.0))));
}
Aggregations