use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class TestChecksumAggregation method testArray.
@Test
public void testArray() {
ArrayType arrayType = new ArrayType(BIGINT);
Block block = createArrayBigintBlock(asList(null, asList(1L, 2L), asList(3L, 4L), asList(5L, 6L)));
assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("checksum"), fromTypes(arrayType), expectedChecksum(arrayType, block), block);
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class TestMapAggAggregation method testDoubleArrayMap.
@Test
public void testDoubleArrayMap() {
ArrayType arrayType = new ArrayType(VARCHAR);
assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of(MapAggregationFunction.NAME), fromTypes(DOUBLE, arrayType), ImmutableMap.of(1.0, ImmutableList.of("a", "b"), 2.0, ImmutableList.of("c", "d"), 3.0, ImmutableList.of("e", "f")), createDoublesBlock(1.0, 2.0, 3.0), createStringArraysBlock(ImmutableList.of(ImmutableList.of("a", "b"), ImmutableList.of("c", "d"), ImmutableList.of("e", "f"))));
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class TestMapAggAggregation method testArrayDoubleMap.
@Test
public void testArrayDoubleMap() {
ArrayType arrayType = new ArrayType(VARCHAR);
assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of(MapAggregationFunction.NAME), fromTypes(arrayType, DOUBLE), 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));
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class TestMapUnionAggregation method testStructural.
@Test
public void testStructural() {
MapType mapType = mapType(DOUBLE, new ArrayType(VARCHAR));
assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of(MapUnionAggregation.NAME), fromTypes(mapType), ImmutableMap.of(1.0, ImmutableList.of("a", "b"), 2.0, ImmutableList.of("c", "d"), 3.0, ImmutableList.of("e", "f"), 4.0, ImmutableList.of("r", "s")), arrayBlockOf(mapType, mapBlockOf(DOUBLE, new ArrayType(VARCHAR), ImmutableMap.of(1.0, ImmutableList.of("a", "b"), 2.0, ImmutableList.of("c", "d"), 3.0, ImmutableList.of("e", "f"))), mapBlockOf(DOUBLE, new ArrayType(VARCHAR), ImmutableMap.of(1.0, ImmutableList.of("x", "y"), 4.0, ImmutableList.of("r", "s"), 3.0, ImmutableList.of("w", "z")))));
mapType = mapType(DOUBLE, mapType(VARCHAR, VARCHAR));
assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of(MapUnionAggregation.NAME), fromTypes(mapType), ImmutableMap.of(1.0, ImmutableMap.of("a", "b"), 2.0, ImmutableMap.of("c", "d"), 3.0, ImmutableMap.of("e", "f")), arrayBlockOf(mapType, mapBlockOf(DOUBLE, mapType(VARCHAR, VARCHAR), ImmutableMap.of(1.0, ImmutableMap.of("a", "b"), 2.0, ImmutableMap.of("c", "d"))), mapBlockOf(DOUBLE, mapType(VARCHAR, VARCHAR), ImmutableMap.of(3.0, ImmutableMap.of("e", "f")))));
mapType = mapType(new ArrayType(VARCHAR), DOUBLE);
assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of(MapUnionAggregation.NAME), fromTypes(mapType), ImmutableMap.of(ImmutableList.of("a", "b"), 1.0, ImmutableList.of("c", "d"), 2.0, ImmutableList.of("e", "f"), 3.0), arrayBlockOf(mapType, mapBlockOf(new ArrayType(VARCHAR), DOUBLE, ImmutableMap.of(ImmutableList.of("a", "b"), 1.0, ImmutableList.of("e", "f"), 3.0)), mapBlockOf(new ArrayType(VARCHAR), DOUBLE, ImmutableMap.of(ImmutableList.of("c", "d"), 2.0))));
}
use of io.trino.spi.type.ArrayType in project trino by trinodb.
the class TestQueryResultRows method shouldHandleNullValuesInArray.
@Test
public void shouldHandleNullValuesInArray() {
List<Column> columns = ImmutableList.of(new Column("_col0", ARRAY, new ClientTypeSignature(ARRAY)));
List<Type> types = ImmutableList.of(new ArrayType(TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE));
List<Page> pages = rowPagesBuilder(types).row(singletonList(null)).build();
TestExceptionConsumer exceptionConsumer = new TestExceptionConsumer();
QueryResultRows rows = queryResultRowsBuilder(getSession()).withColumnsAndTypes(columns, types).withExceptionConsumer(exceptionConsumer).addPages(pages).build();
assertThat(exceptionConsumer.getExceptions()).isEmpty();
assertFalse(rows.isEmpty(), "rows are empty");
assertThat(rows.getTotalRowsCount()).isEqualTo(1);
assertThat(getAllValues(rows)).hasSize(1).containsOnly(singletonList(singletonList(null)));
assertThat(exceptionConsumer.getExceptions()).isEmpty();
}
Aggregations