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));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByNAggregation method testMaxVarcharArray.
@Test
public void testMaxVarcharArray() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature("array(array(bigint))"), parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(3L, 4L)), 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));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByNAggregation method testMaxVarcharDouble.
@Test
public void testMaxVarcharDouble() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature("array(double)"), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, ImmutableList.of(1.0, 2.0), createDoublesBlock(1.0, 2.0, null), createStringsBlock("z", "a", null), createRLEBlock(2L, 3));
assertAggregation(function, ImmutableList.of(0.0, 1.0), createDoublesBlock(0.0, 1.0, 2.0, -1.0), createStringsBlock("zz", "hi", "bb", "a"), createRLEBlock(2L, 4));
assertAggregation(function, ImmutableList.of(0.0, 1.0), createDoublesBlock(0.0, 1.0, null, -1.0), createStringsBlock("zz", "hi", null, "a"), createRLEBlock(2L, 4));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMapAggAggregation method testNull.
@Test
public void testNull() throws Exception {
InternalAggregationFunction doubleDouble = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, new MapType(DOUBLE, DOUBLE).getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE)));
assertAggregation(doubleDouble, ImmutableMap.of(1.0, 2.0), createDoublesBlock(1.0, null, null), createDoublesBlock(2.0, 3.0, 4.0));
assertAggregation(doubleDouble, null, createDoublesBlock(null, null, null), createDoublesBlock(2.0, 3.0, 4.0));
Map<Double, Double> expected = new LinkedHashMap<>();
expected.put(1.0, null);
expected.put(2.0, null);
expected.put(3.0, null);
assertAggregation(doubleDouble, expected, createDoublesBlock(1.0, 2.0, 3.0), createDoublesBlock(null, null, null));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMapUnionAggregation method testSimpleWithNulls.
@Test
public void testSimpleWithNulls() throws Exception {
MapType mapType = new MapType(DOUBLE, VARCHAR);
InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
Map<Object, Object> expected = mapOf(23.0, "aaa", 33.0, null, 43.0, "ccc", 53.0, "ddd", null, "eee");
assertAggregation(aggFunc, expected, arrayBlockOf(mapType, mapBlockOf(DOUBLE, VARCHAR, mapOf(23.0, "aaa", 33.0, null, 53.0, "ddd")), null, mapBlockOf(DOUBLE, VARCHAR, mapOf(43.0, "ccc", 53.0, "ddd", null, "eee"))));
}
Aggregations