Search in sources :

Example 41 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class TestMinMaxByAggregation method testMinDoubleDouble.

@Test
public void testMinDoubleDouble() throws Exception {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE)));
    assertAggregation(function, null, createDoublesBlock(null, null), createDoublesBlock(null, null));
    assertAggregation(function, 3.0, createDoublesBlock(3.0, 2.0, 5.0, 3.0), createDoublesBlock(1.0, 1.5, 2.0, 4.0));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 42 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class TestMinMaxByAggregation method testMaxDoubleVarchar.

@Test
public void testMaxDoubleVarchar() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.DOUBLE)));
    assertAggregation(function, "a", createStringsBlock("z", "a", null), createDoublesBlock(1.0, 2.0, null));
    assertAggregation(function, "hi", createStringsBlock("zz", "hi", null, "a"), createDoublesBlock(0.0, 1.0, null, -1.0));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 43 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class TestMinMaxByAggregation method testMinNull.

@Test
public void testMinNull() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE)));
    assertAggregation(function, 1.0, createDoublesBlock(1.0, null), createDoublesBlock(1.0, 2.0));
    assertAggregation(function, 10.0, createDoublesBlock(10.0, 9.0, 8.0, 11.0), createDoublesBlock(1.0, null, 2.0, null));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 44 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class TestMinMaxByAggregation method testAllRegistered.

@Test
public void testAllRegistered() {
    Set<Type> orderableTypes = getTypes().stream().filter(Type::isOrderable).collect(toImmutableSet());
    for (Type keyType : orderableTypes) {
        for (Type valueType : getTypes()) {
            if (StateCompiler.getSupportedFieldTypes().contains(valueType.getJavaType())) {
                assertNotNull(METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, valueType.getTypeSignature(), valueType.getTypeSignature(), keyType.getTypeSignature())));
                assertNotNull(METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, valueType.getTypeSignature(), valueType.getTypeSignature(), keyType.getTypeSignature())));
            }
        }
    }
}
Also used : DecimalType(com.facebook.presto.spi.type.DecimalType) Type(com.facebook.presto.spi.type.Type) Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 45 with Signature

use of com.facebook.presto.metadata.Signature in project presto by prestodb.

the class TestMinMaxByAggregation method testMinDoubleVarchar.

@Test
public void testMinDoubleVarchar() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.DOUBLE)));
    assertAggregation(function, "z", createStringsBlock("z", "a", "x", "b"), createDoublesBlock(1.0, 2.0, 2.0, 3.0));
    assertAggregation(function, "a", createStringsBlock("zz", "hi", "bb", "a"), createDoublesBlock(0.0, 1.0, 2.0, -1.0));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Aggregations

Signature (com.facebook.presto.metadata.Signature)123 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)96 Test (org.testng.annotations.Test)91 MapType (com.facebook.presto.type.MapType)18 ImmutableList (com.google.common.collect.ImmutableList)16 RowExpression (com.facebook.presto.sql.relational.RowExpression)12 TypeSignature (com.facebook.presto.spi.type.TypeSignature)11 FunctionCall (com.facebook.presto.sql.tree.FunctionCall)11 Block (com.facebook.presto.spi.block.Block)10 Type (com.facebook.presto.spi.type.Type)10 InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)8 Page (com.facebook.presto.spi.Page)8 DecimalType (com.facebook.presto.spi.type.DecimalType)8 CallExpression (com.facebook.presto.sql.relational.CallExpression)8 MethodHandle (java.lang.invoke.MethodHandle)8 MetadataManager (com.facebook.presto.metadata.MetadataManager)7 PlanNode (com.facebook.presto.sql.planner.plan.PlanNode)7 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)7 ConstantExpression (com.facebook.presto.sql.relational.ConstantExpression)7 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)6