Search in sources :

Example 11 with RaptorTableHandle

use of com.facebook.presto.raptor.RaptorTableHandle in project presto by prestodb.

the class TestRaptorMetadata method testCreateBucketedTable.

@Test
public void testCreateBucketedTable() {
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    ConnectorTableMetadata ordersTable = getOrdersTable(ImmutableMap.of(BUCKET_COUNT_PROPERTY, 16, BUCKETED_ON_PROPERTY, ImmutableList.of("custkey", "orderkey")));
    metadata.createTable(SESSION, ordersTable);
    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, "custkey", BIGINT, 2, OptionalInt.of(0), OptionalInt.empty(), false), new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1, OptionalInt.of(1), OptionalInt.empty(), false)));
    assertEquals(raptorTableHandle.getBucketCount(), OptionalInt.of(16));
    assertEquals(getTableDistributionId(tableId), Long.valueOf(1));
    metadata.dropTable(SESSION, tableHandle);
    // create a new table and verify it has a different distribution
    metadata.createTable(SESSION, ordersTable);
    tableId = ((RaptorTableHandle) metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS)).getTableId();
    assertEquals(tableId, 2);
    assertEquals(getTableDistributionId(tableId), Long.valueOf(2));
}
Also used : RaptorTableHandle(com.facebook.presto.raptor.RaptorTableHandle) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Aggregations

RaptorTableHandle (com.facebook.presto.raptor.RaptorTableHandle)11 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)11 Test (org.testng.annotations.Test)11 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)7 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)1 RaptorPartitioningHandle (com.facebook.presto.raptor.RaptorPartitioningHandle)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ConnectorNewTableLayout (com.facebook.presto.spi.ConnectorNewTableLayout)1 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)1 SchemaTableName (com.facebook.presto.spi.SchemaTableName)1