Search in sources :

Example 96 with Signature

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

the class TestMinMaxByNAggregation method testMinVarcharArray.

@Test
public void testMinVarcharArray() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("min_by", AGGREGATE, parseTypeSignature("array(array(bigint))"), parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.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 : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 97 with Signature

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

the class TestMinMaxByNAggregation method testMaxVarcharArray.

@Test
public void testMaxVarcharArray() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature("array(array(bigint))"), parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.BIGINT)));
    assertAggregation(function, ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(3L, 4L)), 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 : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 98 with Signature

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

the class TestMinMaxByNAggregation method testMaxVarcharDouble.

@Test
public void testMaxVarcharDouble() {
    InternalAggregationFunction function = METADATA.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("max_by", AGGREGATE, parseTypeSignature("array(double)"), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR), parseTypeSignature(StandardTypes.BIGINT)));
    assertAggregation(function, ImmutableList.of(1.0, 2.0), createDoublesBlock(1.0, 2.0, null), createStringsBlock("z", "a", null), createRLEBlock(2L, 3));
    assertAggregation(function, ImmutableList.of(0.0, 1.0), createDoublesBlock(0.0, 1.0, 2.0, -1.0), createStringsBlock("zz", "hi", "bb", "a"), createRLEBlock(2L, 4));
    assertAggregation(function, ImmutableList.of(0.0, 1.0), createDoublesBlock(0.0, 1.0, null, -1.0), createStringsBlock("zz", "hi", null, "a"), createRLEBlock(2L, 4));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 99 with Signature

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

the class TestMapAggAggregation method testNull.

@Test
public void testNull() throws Exception {
    InternalAggregationFunction doubleDouble = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, new MapType(DOUBLE, DOUBLE).getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE)));
    assertAggregation(doubleDouble, ImmutableMap.of(1.0, 2.0), createDoublesBlock(1.0, null, null), createDoublesBlock(2.0, 3.0, 4.0));
    assertAggregation(doubleDouble, null, createDoublesBlock(null, null, null), createDoublesBlock(2.0, 3.0, 4.0));
    Map<Double, Double> expected = new LinkedHashMap<>();
    expected.put(1.0, null);
    expected.put(2.0, null);
    expected.put(3.0, null);
    assertAggregation(doubleDouble, expected, createDoublesBlock(1.0, 2.0, 3.0), createDoublesBlock(null, null, null));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) MapType(com.facebook.presto.type.MapType) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test)

Example 100 with Signature

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

the class TestMapUnionAggregation method testSimpleWithNulls.

@Test
public void testSimpleWithNulls() throws Exception {
    MapType mapType = new MapType(DOUBLE, VARCHAR);
    InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), mapType.getTypeSignature()));
    Map<Object, Object> expected = mapOf(23.0, "aaa", 33.0, null, 43.0, "ccc", 53.0, "ddd", null, "eee");
    assertAggregation(aggFunc, expected, arrayBlockOf(mapType, mapBlockOf(DOUBLE, VARCHAR, mapOf(23.0, "aaa", 33.0, null, 53.0, "ddd")), null, mapBlockOf(DOUBLE, VARCHAR, mapOf(43.0, "ccc", 53.0, "ddd", null, "eee"))));
}
Also used : Signature(com.facebook.presto.metadata.Signature) MapType(com.facebook.presto.type.MapType) 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