use of com.facebook.presto.metadata.MetadataManager in project presto by prestodb.
the class TestUnnestOperator method testUnnestWithArray.
@Test
public void testUnnestWithArray() throws Exception {
MetadataManager metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(array(bigint))"));
Type mapType = metadata.getType(parseTypeSignature("map(array(bigint),array(bigint))"));
List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(2, 4), ImmutableList.of(3, 6)), mapBlockOf(new ArrayType(BIGINT), new ArrayType(BIGINT), ImmutableMap.of(ImmutableList.of(4, 8), ImmutableList.of(5, 10)))).row(2L, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(99, 198)), null).row(3L, null, null).pageBreak().row(6, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(7, 14), ImmutableList.of(8, 16)), mapBlockOf(new ArrayType(BIGINT), new ArrayType(BIGINT), ImmutableMap.of(ImmutableList.of(9, 18), ImmutableList.of(10, 20), ImmutableList.of(11, 22), ImmutableList.of(12, 24)))).build();
OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), false);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, new ArrayType(BIGINT), new ArrayType(BIGINT), new ArrayType(BIGINT)).row(1L, ImmutableList.of(2L, 4L), ImmutableList.of(4L, 8L), ImmutableList.of(5L, 10L)).row(1L, ImmutableList.of(3L, 6L), null, null).row(2L, ImmutableList.of(99L, 198L), null, null).row(6L, ImmutableList.of(7L, 14L), ImmutableList.of(9L, 18L), ImmutableList.of(10L, 20L)).row(6L, ImmutableList.of(8L, 16L), ImmutableList.of(11L, 22L), ImmutableList.of(12L, 24L)).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Aggregations