Search in sources :

Example 16 with MetadataManager

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);
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) ArrayType(com.facebook.presto.type.ArrayType) Type(com.facebook.presto.spi.type.Type) MetadataManager(com.facebook.presto.metadata.MetadataManager) MetadataManager.createTestMetadataManager(com.facebook.presto.metadata.MetadataManager.createTestMetadataManager) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

MetadataManager (com.facebook.presto.metadata.MetadataManager)16 Test (org.testng.annotations.Test)10 Page (com.facebook.presto.spi.Page)9 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)9 Signature (com.facebook.presto.metadata.Signature)7 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)7 MaterializedResult (com.facebook.presto.testing.MaterializedResult)7 MetadataManager.createTestMetadataManager (com.facebook.presto.metadata.MetadataManager.createTestMetadataManager)5 InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)5 ArrayType (com.facebook.presto.type.ArrayType)5 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)4 HashAggregationOperatorFactory (com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)4 DataSize (io.airlift.units.DataSize)4 ConnectorId.createInformationSchemaConnectorId (com.facebook.presto.connector.ConnectorId.createInformationSchemaConnectorId)3 ConnectorId.createSystemTablesConnectorId (com.facebook.presto.connector.ConnectorId.createSystemTablesConnectorId)3 InformationSchemaConnector (com.facebook.presto.connector.informationSchema.InformationSchemaConnector)3 SystemConnector (com.facebook.presto.connector.system.SystemConnector)3 Catalog (com.facebook.presto.metadata.Catalog)3 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)3 Type (com.facebook.presto.spi.type.Type)3