Search in sources :

Example 1 with RaptorPartitioningHandle

use of io.trino.plugin.raptor.legacy.RaptorPartitioningHandle in project trino by trinodb.

the class TestRaptorMetadata method testCreateBucketedTableAsSelect.

@Test
public void testCreateBucketedTableAsSelect() {
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    ConnectorTableMetadata ordersTable = getOrdersTable(ImmutableMap.of(BUCKET_COUNT_PROPERTY, 32, BUCKETED_ON_PROPERTY, ImmutableList.of("orderkey", "custkey")));
    ConnectorTableLayout layout = metadata.getNewTableLayout(SESSION, ordersTable).get();
    assertEquals(layout.getPartitionColumns(), ImmutableList.of("orderkey", "custkey"));
    assertTrue(layout.getPartitioning().isPresent());
    assertInstanceOf(layout.getPartitioning().get(), RaptorPartitioningHandle.class);
    RaptorPartitioningHandle partitioning = (RaptorPartitioningHandle) layout.getPartitioning().get();
    assertEquals(partitioning.getDistributionId(), 1);
    ConnectorOutputTableHandle outputHandle = metadata.beginCreateTable(SESSION, ordersTable, Optional.of(layout));
    metadata.finishCreateTable(SESSION, outputHandle, ImmutableList.of(), ImmutableList.of());
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    assertInstanceOf(tableHandle, RaptorTableHandle.class);
    RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
    assertEquals(raptorTableHandle.getTableId(), 1);
    long tableId = raptorTableHandle.getTableId();
    MetadataDao metadataDao = dbi.onDemand(MetadataDao.class);
    assertTableColumnsEqual(metadataDao.listBucketColumns(tableId), ImmutableList.of(new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1, 0, OptionalInt.of(0), OptionalInt.empty(), false), new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, 1, OptionalInt.of(1), OptionalInt.empty(), false)));
    assertEquals(raptorTableHandle.getBucketCount(), OptionalInt.of(32));
    assertEquals(getTableDistributionId(tableId), Long.valueOf(1));
    metadata.dropTable(SESSION, tableHandle);
}
Also used : ConnectorOutputTableHandle(io.trino.spi.connector.ConnectorOutputTableHandle) RaptorTableHandle(io.trino.plugin.raptor.legacy.RaptorTableHandle) ConnectorTableLayout(io.trino.spi.connector.ConnectorTableLayout) RaptorPartitioningHandle(io.trino.plugin.raptor.legacy.RaptorPartitioningHandle) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Test(org.testng.annotations.Test)

Aggregations

RaptorPartitioningHandle (io.trino.plugin.raptor.legacy.RaptorPartitioningHandle)1 RaptorTableHandle (io.trino.plugin.raptor.legacy.RaptorTableHandle)1 ConnectorOutputTableHandle (io.trino.spi.connector.ConnectorOutputTableHandle)1 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)1 ConnectorTableLayout (io.trino.spi.connector.ConnectorTableLayout)1 ConnectorTableMetadata (io.trino.spi.connector.ConnectorTableMetadata)1 Test (org.testng.annotations.Test)1