Search in sources :

Example 21 with Signature

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

the class TestArrayAggregation method testEmpty.

@Test
public void testEmpty() throws Exception {
    InternalAggregationFunction bigIntAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("array_agg", AGGREGATE, parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.BIGINT)));
    assertAggregation(bigIntAgg, null, createLongsBlock(new Long[] {}));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 22 with Signature

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

the class TestArrayAggregation method testArray.

@Test
public void testArray() throws Exception {
    InternalAggregationFunction varcharAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("array_agg", AGGREGATE, parseTypeSignature("array(array(bigint))"), parseTypeSignature("array(bigint)")));
    assertAggregation(varcharAgg, Arrays.asList(Arrays.asList(1L), Arrays.asList(1L, 2L), Arrays.asList(1L, 2L, 3L)), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(1L), ImmutableList.of(1L, 2L), ImmutableList.of(1L, 2L, 3L))));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 23 with Signature

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

the class TestArrayAggregation method testBoolean.

@Test
public void testBoolean() throws Exception {
    InternalAggregationFunction booleanAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("array_agg", AGGREGATE, parseTypeSignature("array(boolean)"), parseTypeSignature(StandardTypes.BOOLEAN)));
    assertAggregation(booleanAgg, Arrays.asList(true, false), createBooleansBlock(new Boolean[] { true, false }));
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Test(org.testng.annotations.Test)

Example 24 with Signature

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

the class TestChecksumAggregation method testLongDecimal.

@Test
public void testLongDecimal() throws Exception {
    InternalAggregationFunction decimalAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("checksum", AGGREGATE, parseTypeSignature(VARBINARY), parseTypeSignature("decimal(19,2)")));
    Block block = createLongDecimalsBlock("11.11", "22.22", null, "33.33", "44.44");
    DecimalType longDecimalType = DecimalType.createDecimalType(19);
    assertAggregation(decimalAgg, expectedChecksum(longDecimalType, block), block);
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Block(com.facebook.presto.spi.block.Block) BlockAssertions.createLongsBlock(com.facebook.presto.block.BlockAssertions.createLongsBlock) BlockAssertions.createShortDecimalsBlock(com.facebook.presto.block.BlockAssertions.createShortDecimalsBlock) BlockAssertions.createLongDecimalsBlock(com.facebook.presto.block.BlockAssertions.createLongDecimalsBlock) BlockAssertions.createStringsBlock(com.facebook.presto.block.BlockAssertions.createStringsBlock) BlockAssertions.createArrayBigintBlock(com.facebook.presto.block.BlockAssertions.createArrayBigintBlock) BlockAssertions.createBooleansBlock(com.facebook.presto.block.BlockAssertions.createBooleansBlock) BlockAssertions.createDoublesBlock(com.facebook.presto.block.BlockAssertions.createDoublesBlock) DecimalType(com.facebook.presto.spi.type.DecimalType) Test(org.testng.annotations.Test)

Example 25 with Signature

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

the class TestChecksumAggregation method testDouble.

@Test
public void testDouble() throws Exception {
    InternalAggregationFunction doubleAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature("checksum", AGGREGATE, parseTypeSignature(VARBINARY), parseTypeSignature(DOUBLE)));
    Block block = createDoublesBlock(null, 2.0, null, 3.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN);
    assertAggregation(doubleAgg, expectedChecksum(DoubleType.DOUBLE, block), block);
}
Also used : Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) Block(com.facebook.presto.spi.block.Block) BlockAssertions.createLongsBlock(com.facebook.presto.block.BlockAssertions.createLongsBlock) BlockAssertions.createShortDecimalsBlock(com.facebook.presto.block.BlockAssertions.createShortDecimalsBlock) BlockAssertions.createLongDecimalsBlock(com.facebook.presto.block.BlockAssertions.createLongDecimalsBlock) BlockAssertions.createStringsBlock(com.facebook.presto.block.BlockAssertions.createStringsBlock) BlockAssertions.createArrayBigintBlock(com.facebook.presto.block.BlockAssertions.createArrayBigintBlock) BlockAssertions.createBooleansBlock(com.facebook.presto.block.BlockAssertions.createBooleansBlock) BlockAssertions.createDoublesBlock(com.facebook.presto.block.BlockAssertions.createDoublesBlock) 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