Search in sources :

Example 36 with Signature

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

the class TestMapAggAggregation method testArrayDoubleMap.

@Test
public void testArrayDoubleMap() throws Exception {
    ArrayType arrayType = new ArrayType(VARCHAR);
    MapType mapType = new MapType(arrayType, DOUBLE);
    InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), arrayType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE)));
    assertAggregation(aggFunc, ImmutableMap.of(ImmutableList.of("a", "b"), 1.0, ImmutableList.of("c", "d"), 2.0, ImmutableList.of("e", "f"), 3.0), createStringArraysBlock(ImmutableList.of(ImmutableList.of("a", "b"), ImmutableList.of("c", "d"), ImmutableList.of("e", "f"))), createDoublesBlock(1.0, 2.0, 3.0));
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) MapType(com.facebook.presto.type.MapType) Test(org.testng.annotations.Test)

Example 37 with Signature

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

the class TestMapUnionAggregation method testSimpleWithDuplicates.

@Test
public void testSimpleWithDuplicates() throws Exception {
    MapType mapType = new MapType(DOUBLE, VARCHAR);
    InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
    assertAggregation(aggFunc, ImmutableMap.of(23.0, "aaa", 33.0, "bbb", 43.0, "ccc", 53.0, "ddd", 13.0, "eee"), arrayBlockOf(mapType, mapBlockOf(DOUBLE, VARCHAR, ImmutableMap.of(23.0, "aaa", 33.0, "bbb", 53.0, "ddd")), mapBlockOf(DOUBLE, VARCHAR, ImmutableMap.of(43.0, "ccc", 53.0, "ddd", 13.0, "eee"))));
    mapType = new MapType(DOUBLE, BIGINT);
    aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
    assertAggregation(aggFunc, ImmutableMap.of(1.0, 99L, 2.0, 99L, 3.0, 99L, 4.0, 44L), arrayBlockOf(mapType, mapBlockOf(DOUBLE, BIGINT, ImmutableMap.of(1.0, 99L, 2.0, 99L, 3.0, 99L)), mapBlockOf(DOUBLE, BIGINT, ImmutableMap.of(1.0, 44L, 2.0, 44L, 4.0, 44L))));
    mapType = new MapType(BOOLEAN, BIGINT);
    aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
    assertAggregation(aggFunc, ImmutableMap.of(false, 12L, true, 13L), arrayBlockOf(mapType, mapBlockOf(BOOLEAN, BIGINT, ImmutableMap.of(false, 12L)), mapBlockOf(BOOLEAN, BIGINT, ImmutableMap.of(true, 13L, false, 33L))));
}
Also used : Signature(com.facebook.presto.metadata.Signature) MapType(com.facebook.presto.type.MapType) Test(org.testng.annotations.Test)

Example 38 with Signature

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

the class TestMinMaxByAggregation method testMaxLongDecimalDecimal.

@Test
public void testMaxLongDecimalDecimal() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature("decimal(19,1)"), parseTypeSignature("decimal(19,1)"), parseTypeSignature("decimal(19,1)")));
    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 : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 39 with Signature

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

the class TestMinMaxByAggregation method testMinShortDecimalDecimal.

@Test
public void testMinShortDecimalDecimal() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("decimal(10,1)"), parseTypeSignature("decimal(10,1)"), parseTypeSignature("decimal(10,1)")));
    assertAggregation(function, SqlDecimal.of("2.2"), createShortDecimalsBlock("1.1", "2.2", "3.3"), createShortDecimalsBlock("1.2", "1.0", "2.0"));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 40 with Signature

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

the class TestMinMaxByAggregation method testMinLongDecimalDecimal.

@Test
public void testMinLongDecimalDecimal() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("decimal(19,1)"), parseTypeSignature("decimal(19,1)"), parseTypeSignature("decimal(19,1)")));
    assertAggregation(function, SqlDecimal.of("2.2"), createLongDecimalsBlock("1.1", "2.2", "3.3"), createLongDecimalsBlock("1.2", "1.0", "2.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