Search in sources :

Example 66 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMaxUnknown.

@Test
public void testMaxUnknown() {
    InternalAggregationFunction unknownKey = getMaxByAggregation(UNKNOWN, DOUBLE);
    assertAggregation(unknownKey, null, createBooleansBlock(null, null), createDoublesBlock(1.0, 2.0));
    InternalAggregationFunction unknownValue = getMaxByAggregation(DOUBLE, UNKNOWN);
    assertAggregation(unknownValue, null, createDoublesBlock(1.0, 2.0), createBooleansBlock(null, null));
}
Also used : InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 67 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMaxLongArrayLong.

@Test
public void testMaxLongArrayLong() {
    InternalAggregationFunction function = getMaxByAggregation(BIGINT, new ArrayType(BIGINT));
    assertAggregation(function, 1L, createLongsBlock(1L, 2L, 2L, 3L), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(8L, 9L), ImmutableList.of(1L, 2L), ImmutableList.of(6L, 7L), ImmutableList.of(1L, 1L))));
    assertAggregation(function, 2L, createLongsBlock(0L, 1L, 2L, -1L), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(-8L, 9L), ImmutableList.of(-6L, 7L), ImmutableList.of(-1L, -3L), ImmutableList.of(-1L))));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 68 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMinShortDecimalDecimal.

@Test
public void testMinShortDecimalDecimal() {
    Type decimalType = createDecimalType(10, 1);
    InternalAggregationFunction function = getMinByAggregation(decimalType, decimalType);
    assertAggregation(function, SqlDecimal.of("2.2"), createShortDecimalsBlock("1.1", "2.2", "3.3"), createShortDecimalsBlock("1.2", "1.0", "2.0"));
}
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)

Example 69 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMaxLongDecimalDecimal.

@Test
public void testMaxLongDecimalDecimal() {
    Type decimalType = createDecimalType(19, 1);
    InternalAggregationFunction function = getMaxByAggregation(decimalType, decimalType);
    assertAggregation(function, SqlDecimal.of("3.3"), createLongDecimalsBlock("1.1", "2.2", "3.3", "4.4"), createLongDecimalsBlock("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)

Example 70 with InternalAggregationFunction

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

the class TestMinMaxByAggregation method testMaxUnknownLongArray.

@Test
public void testMaxUnknownLongArray() {
    InternalAggregationFunction function = getMaxByAggregation(new ArrayType(BIGINT), UNKNOWN);
    assertAggregation(function, null, createArrayBigintBlock(asList(asList(3L, 3L), null, asList(1L, 2L))), createArrayBigintBlock(asList(null, null, null)));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) 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