use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByAggregation method testMaxDoubleDouble.
@Test
public void testMaxDoubleDouble() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE)));
assertAggregation(function, null, createDoublesBlock(null, null), createDoublesBlock(null, null));
assertAggregation(function, 2.0, createDoublesBlock(3.0, 2.0, null), createDoublesBlock(1.0, 1.5, null));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByNAggregation method testMinVarcharDouble.
@Test
public void testMinVarcharDouble() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("array(double)"), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, ImmutableList.of(2.0, 3.0), createDoublesBlock(1.0, 2.0, 2.0, 3.0), createStringsBlock("z", "a", "x", "b"), createRLEBlock(2L, 4));
assertAggregation(function, ImmutableList.of(-1.0, 2.0), createDoublesBlock(0.0, 1.0, 2.0, -1.0), createStringsBlock("zz", "hi", "bb", "a"), createRLEBlock(2L, 4));
assertAggregation(function, ImmutableList.of(-1.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 TestMinMaxByNAggregation method testMaxDoubleDouble.
@Test
public void testMaxDoubleDouble() throws Exception {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature("array(double)"), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, Arrays.asList((Double) null), createDoublesBlock(1.0, null), createDoublesBlock(3.0, 5.0), createRLEBlock(1L, 2));
assertAggregation(function, null, createDoublesBlock(null, null), createDoublesBlock(null, null), createRLEBlock(1L, 2));
assertAggregation(function, Arrays.asList(1.0), createDoublesBlock(null, 1.0, null, null), createDoublesBlock(null, 0.0, null, null), createRLEBlock(2L, 4));
assertAggregation(function, Arrays.asList(1.0), createDoublesBlock(1.0), createDoublesBlock(0.0), createRLEBlock(2L, 1));
assertAggregation(function, null, createDoublesBlock(), createDoublesBlock(), createRLEBlock(2L, 0));
assertAggregation(function, ImmutableList.of(2.5), createDoublesBlock(2.5, 2.0, 5.0, 3.0), createDoublesBlock(4.0, 1.5, 2.0, 3.0), createRLEBlock(1L, 4));
assertAggregation(function, ImmutableList.of(2.5, 3.0), createDoublesBlock(2.5, 2.0, 5.0, 3.0), createDoublesBlock(4.0, 1.5, 2.0, 3.0), createRLEBlock(2L, 4));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByNAggregation method testMinDoubleVarchar.
@Test
public void testMinDoubleVarchar() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("array(varchar)"), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, ImmutableList.of("z", "a"), createStringsBlock("z", "a", "x", "b"), createDoublesBlock(1.0, 2.0, 2.0, 3.0), createRLEBlock(2L, 4));
assertAggregation(function, ImmutableList.of("a", "zz"), createStringsBlock("zz", "hi", "bb", "a"), createDoublesBlock(0.0, 1.0, 2.0, -1.0), createRLEBlock(2L, 4));
assertAggregation(function, ImmutableList.of("a", "zz"), createStringsBlock("zz", "hi", null, "a"), createDoublesBlock(0.0, 1.0, null, -1.0), createRLEBlock(2L, 4));
}
use of com.facebook.presto.metadata.Signature in project presto by prestodb.
the class TestMinMaxByNAggregation method testMaxDoubleVarchar.
@Test
public void testMaxDoubleVarchar() {
InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature("array(varchar)"), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.BIGINT)));
assertAggregation(function, ImmutableList.of("a", "z"), createStringsBlock("z", "a", null), createDoublesBlock(1.0, 2.0, null), createRLEBlock(2L, 3));
assertAggregation(function, ImmutableList.of("bb", "hi"), createStringsBlock("zz", "hi", "bb", "a"), createDoublesBlock(0.0, 1.0, 2.0, -1.0), createRLEBlock(2L, 4));
assertAggregation(function, ImmutableList.of("hi", "zz"), createStringsBlock("zz", "hi", null, "a"), createDoublesBlock(0.0, 1.0, null, -1.0), createRLEBlock(2L, 4));
}
Aggregations