Search in sources :

Example 21 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMinLongArraySlice.

@Test
public void testMinLongArraySlice() {
    InternalAggregationFunction function = getMinByAggregation(VARCHAR, new ArrayType(BIGINT));
    assertAggregation(function, "c", createStringsBlock("a", "b", "c"), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 22 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMaxNull.

@Test
public void testMaxNull() {
    InternalAggregationFunction function = getMaxByAggregation(DOUBLE, DOUBLE);
    assertAggregation(function, null, createDoublesBlock(1.0, null), createDoublesBlock(1.0, 2.0));
    assertAggregation(function, 10.0, createDoublesBlock(8.0, 9.0, 10.0, 11.0), createDoublesBlock(-2.0, null, -1.0, null));
}
Also used : InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 23 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMinBooleanLongArray.

@Test
public void testMinBooleanLongArray() {
    InternalAggregationFunction function = getMinByAggregation(new ArrayType(BIGINT), BOOLEAN);
    assertAggregation(function, null, createArrayBigintBlock(asList(asList(3L, 4L), null, null)), createBooleansBlock(true, false, true));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 24 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMaxDoubleLongArray.

@Test
public void testMaxDoubleLongArray() {
    InternalAggregationFunction function = getMaxByAggregation(new ArrayType(BIGINT), DOUBLE);
    assertAggregation(function, null, createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))), createDoublesBlock(1.0, 2.0, null));
    assertAggregation(function, asList(2L, 2L), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))), createDoublesBlock(0.0, 1.0, 2.0));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 25 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMaxShortDecimalDecimal.

@Test
public void testMaxShortDecimalDecimal() {
    Type decimalType = createDecimalType(10, 1);
    InternalAggregationFunction function = getMaxByAggregation(decimalType, decimalType);
    assertAggregation(function, SqlDecimal.of("3.3"), createShortDecimalsBlock("1.1", "2.2", "3.3", "4.4"), createShortDecimalsBlock("1.2", "1.0", "2.0", "1.5"));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) StructuralTestUtil.mapType(com.facebook.presto.util.StructuralTestUtil.mapType) Type(com.facebook.presto.common.type.Type) RowType(com.facebook.presto.common.type.RowType) DecimalType.createDecimalType(com.facebook.presto.common.type.DecimalType.createDecimalType) 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