Search in sources :

Example 91 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestMinMaxByAggregation method testMinLongArraySlice.

@Test
public void testMinLongArraySlice() {
    InternalAggregationFunction function = getMinByAggregation(VARCHAR, new ArrayType(BIGINT));
    assertAggregation(function, "c", createStringsBlock("a", "b", "c"), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 92 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestMinMaxByAggregation method testMinBooleanLongArray.

@Test
public void testMinBooleanLongArray() {
    InternalAggregationFunction function = getMinByAggregation(new ArrayType(BIGINT), BOOLEAN);
    assertAggregation(function, null, createArrayBigintBlock(asList(asList(3L, 4L), null, null)), createBooleansBlock(true, false, true));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 93 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestMinMaxByAggregation method testMaxDoubleLongArray.

@Test
public void testMaxDoubleLongArray() {
    InternalAggregationFunction function = getMaxByAggregation(new ArrayType(BIGINT), DOUBLE);
    assertAggregation(function, null, createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))), createDoublesBlock(1.0, 2.0, null));
    assertAggregation(function, asList(2L, 2L), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))), createDoublesBlock(0.0, 1.0, 2.0));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Example 94 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestMinMaxByAggregation method testMinLongArrayLong.

@Test
public void testMinLongArrayLong() {
    InternalAggregationFunction function = getMinByAggregation(BIGINT, new ArrayType(BIGINT));
    assertAggregation(function, 3L, 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, -1L, 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 95 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestRowExpressionSerde method testArrayGet.

@Test
public void testArrayGet() {
    assertEquals(getRoundTrip("(ARRAY [1, 2, 3])[1]", false), call(SUBSCRIPT.name(), operator(SUBSCRIPT, new ArrayType(INTEGER), BIGINT), INTEGER, call("array_constructor", function("array_constructor", INTEGER, INTEGER, INTEGER), new ArrayType(INTEGER), constant(1L, INTEGER), constant(2L, INTEGER), constant(3L, INTEGER)), constant(1L, INTEGER)));
    assertEquals(getRoundTrip("(ARRAY [1, 2, 3])[1]", true), constant(1L, INTEGER));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) Test(org.testng.annotations.Test)

Aggregations

ArrayType (com.facebook.presto.common.type.ArrayType)287 Test (org.testng.annotations.Test)219 Type (com.facebook.presto.common.type.Type)99 RowType (com.facebook.presto.common.type.RowType)79 ArrayList (java.util.ArrayList)58 ImmutableList (com.google.common.collect.ImmutableList)54 List (java.util.List)51 MapType (com.facebook.presto.common.type.MapType)39 DecimalType.createDecimalType (com.facebook.presto.common.type.DecimalType.createDecimalType)36 Arrays.asList (java.util.Arrays.asList)34 Collections.singletonList (java.util.Collections.singletonList)33 MessageType (org.apache.parquet.schema.MessageType)30 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)28 VarcharType.createUnboundedVarcharType (com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType)27 MessageTypeParser.parseMessageType (org.apache.parquet.schema.MessageTypeParser.parseMessageType)27 InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)26 PrimitiveType (org.apache.parquet.schema.PrimitiveType)26 StructuralTestUtil.mapType (com.facebook.presto.tests.StructuralTestUtil.mapType)24 Block (com.facebook.presto.common.block.Block)23 DecimalType (com.facebook.presto.common.type.DecimalType)17