Search in sources :

Example 36 with InternalAggregationFunction

use of com.facebook.presto.operator.aggregation.InternalAggregationFunction in project presto by prestodb.

the class TestMinMaxByNAggregation method testMinVarcharDouble.

@Test
public void testMinVarcharDouble() {
    InternalAggregationFunction function = getMinByAggregation(DOUBLE, VARCHAR, 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));
}
Also used : InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 37 with InternalAggregationFunction

use of com.facebook.presto.operator.aggregation.InternalAggregationFunction in project presto by prestodb.

the class TestMinMaxByNAggregation method testMinVarcharArray.

@Test
public void testMinVarcharArray() {
    InternalAggregationFunction function = getMinByAggregation(new ArrayType(BIGINT), VARCHAR, 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));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 38 with InternalAggregationFunction

use of com.facebook.presto.operator.aggregation.InternalAggregationFunction in project presto by prestodb.

the class TestMinMaxByNAggregation method testMinArrayVarchar.

@Test
public void testMinArrayVarchar() {
    InternalAggregationFunction function = getMinByAggregation(VARCHAR, new ArrayType(BIGINT), BIGINT);
    assertAggregation(function, ImmutableList.of("b", "x", "z"), createStringsBlock("z", "a", "x", "b"), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(2L, 3L), ImmutableList.of(0L, 3L), ImmutableList.of(0L, 2L))), createRLEBlock(3L, 4));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 39 with InternalAggregationFunction

use of com.facebook.presto.operator.aggregation.InternalAggregationFunction in project presto by prestodb.

the class TestMinMaxByNAggregation method testMaxDoubleVarchar.

@Test
public void testMaxDoubleVarchar() {
    InternalAggregationFunction function = getMaxByAggregation(VARCHAR, DOUBLE, 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));
}
Also used : InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 40 with InternalAggregationFunction

use of com.facebook.presto.operator.aggregation.InternalAggregationFunction in project presto by prestodb.

the class TestMinMaxByNAggregation method testMinDoubleDouble.

@Test
public void testMinDoubleDouble() {
    InternalAggregationFunction function = getMinByAggregation(DOUBLE, DOUBLE, BIGINT);
    assertAggregation(function, Arrays.asList((Double) null), createDoublesBlock(1.0, null), createDoublesBlock(5.0, 3.0), createRLEBlock(1L, 2));
    assertAggregation(function, null, createDoublesBlock(null, null), createDoublesBlock(null, null), createRLEBlock(1L, 2));
    assertAggregation(function, ImmutableList.of(2.0), 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.0, 5.0), createDoublesBlock(2.5, 2.0, 5.0, 3.0), createDoublesBlock(4.0, 1.5, 2.0, 3.0), createRLEBlock(2L, 4));
}
Also used : InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Aggregations

InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)89 Test (org.testng.annotations.Test)73 ArrayType (com.facebook.presto.common.type.ArrayType)31 AggregationMetadata (com.facebook.presto.operator.aggregation.AggregationMetadata)20 Type (com.facebook.presto.common.type.Type)17 ParametricAggregation (com.facebook.presto.operator.aggregation.ParametricAggregation)14 AggregationImplementation (com.facebook.presto.operator.aggregation.AggregationImplementation)13 TypeSignature (com.facebook.presto.common.type.TypeSignature)12 TypeSignature.parseTypeSignature (com.facebook.presto.common.type.TypeSignature.parseTypeSignature)12 Signature (com.facebook.presto.spi.function.Signature)12 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)9 DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)8 Page (com.facebook.presto.common.Page)8 GenericAccumulatorFactoryBinder (com.facebook.presto.operator.aggregation.GenericAccumulatorFactoryBinder)8 AccumulatorStateDescriptor (com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)7 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)6 HashAggregationOperatorFactory (com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)6 DataSize (io.airlift.units.DataSize)6 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)5 DecimalType.createDecimalType (com.facebook.presto.common.type.DecimalType.createDecimalType)4