Search in sources :

Example 1 with RaptorTableHandle

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

the class TestRaptorMetadata method testRenameTable.

@Test
public void testRenameTable() {
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    metadata.createTable(SESSION, getOrdersTable(), false);
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    assertInstanceOf(tableHandle, RaptorTableHandle.class);
    RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
    SchemaTableName renamedTable = new SchemaTableName(raptorTableHandle.getSchemaName(), "orders_renamed");
    metadata.renameTable(SESSION, raptorTableHandle, renamedTable);
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    ConnectorTableHandle renamedTableHandle = metadata.getTableHandle(SESSION, renamedTable);
    assertNotNull(renamedTableHandle);
    assertEquals(((RaptorTableHandle) renamedTableHandle).getTableName(), renamedTable.getTableName());
}
Also used : RaptorTableHandle(io.trino.plugin.raptor.legacy.RaptorTableHandle) SchemaTableName(io.trino.spi.connector.SchemaTableName) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 2 with RaptorTableHandle

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

the class TestRaptorMetadata method testDropColumn.

@Test
public void testDropColumn() {
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    metadata.createTable(SESSION, buildTable(ImmutableMap.of(), tableMetadataBuilder(DEFAULT_TEST_ORDERS).column("orderkey", BIGINT).column("price", BIGINT)), false);
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    assertInstanceOf(tableHandle, RaptorTableHandle.class);
    RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
    ColumnHandle lastColumn = metadata.getColumnHandles(SESSION, tableHandle).get("orderkey");
    metadata.dropColumn(SESSION, raptorTableHandle, lastColumn);
    assertNull(metadata.getColumnHandles(SESSION, tableHandle).get("orderkey"));
}
Also used : RaptorColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle) ColumnHandle(io.trino.spi.connector.ColumnHandle) RaptorTableHandle(io.trino.plugin.raptor.legacy.RaptorTableHandle) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 3 with RaptorTableHandle

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

the class TestRaptorMetadata method testTablePropertiesWithOrganization.

@Test
public void testTablePropertiesWithOrganization() {
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    ConnectorTableMetadata ordersTable = getOrdersTable(ImmutableMap.of(ORDERING_PROPERTY, ImmutableList.of("orderdate", "custkey"), ORGANIZED_PROPERTY, true));
    metadata.createTable(SESSION, ordersTable, false);
    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);
    // verify sort columns
    List<TableColumn> sortColumns = metadataDao.listSortColumns(tableId);
    assertTableColumnsEqual(sortColumns, ImmutableList.of(new TableColumn(DEFAULT_TEST_ORDERS, "orderdate", DATE, 4, 3, OptionalInt.empty(), OptionalInt.of(0), false), new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, 1, OptionalInt.empty(), OptionalInt.of(1), false)));
    // verify organization
    assertTrue(metadataDao.getTableInformation(tableId).isOrganized());
    metadata.dropTable(SESSION, tableHandle);
}
Also used : RaptorTableHandle(io.trino.plugin.raptor.legacy.RaptorTableHandle) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 4 with RaptorTableHandle

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

the class TestRaptorMetadata method testSortOrderProperty.

@Test
public void testSortOrderProperty() {
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    ConnectorTableMetadata ordersTable = getOrdersTable(ImmutableMap.of(ORDERING_PROPERTY, ImmutableList.of("orderdate", "custkey")));
    metadata.createTable(SESSION, ordersTable, false);
    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);
    // verify sort columns
    List<TableColumn> sortColumns = metadataDao.listSortColumns(tableId);
    assertTableColumnsEqual(sortColumns, ImmutableList.of(new TableColumn(DEFAULT_TEST_ORDERS, "orderdate", DATE, 4, 3, OptionalInt.empty(), OptionalInt.of(0), false), new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, 1, OptionalInt.empty(), OptionalInt.of(1), false)));
    // verify temporal column is not set
    assertEquals(metadataDao.getTemporalColumnId(tableId), null);
    metadata.dropTable(SESSION, tableHandle);
}
Also used : RaptorTableHandle(io.trino.plugin.raptor.legacy.RaptorTableHandle) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 5 with RaptorTableHandle

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

the class TestRaptorMetadata method testTransactionDelete.

@Test
public void testTransactionDelete() {
    // creating a table allocates a transaction
    long transactionId = 1;
    metadata.createTable(SESSION, getOrdersTable(), false);
    assertTrue(transactionSuccessful(transactionId));
    // start delete
    transactionId++;
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    tableHandle = metadata.beginDelete(SESSION, tableHandle);
    // verify transaction is assigned for deletion handle
    assertInstanceOf(tableHandle, RaptorTableHandle.class);
    RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
    assertEquals(raptorTableHandle.getTableId(), 1);
    assertEquals(raptorTableHandle.getTransactionId(), OptionalLong.of(transactionId));
    // transaction is in progress
    assertTrue(transactionExists(transactionId));
    assertNull(transactionSuccessful(transactionId));
    // rollback delete
    metadata.rollback();
    assertTrue(transactionExists(transactionId));
    assertFalse(transactionSuccessful(transactionId));
    // start another delete
    transactionId++;
    tableHandle = metadata.beginDelete(SESSION, tableHandle);
    // transaction is in progress
    assertTrue(transactionExists(transactionId));
    assertNull(transactionSuccessful(transactionId));
    // commit delete
    metadata.finishDelete(SESSION, tableHandle, ImmutableList.of());
    assertTrue(transactionExists(transactionId));
    assertTrue(transactionSuccessful(transactionId));
}
Also used : RaptorTableHandle(io.trino.plugin.raptor.legacy.RaptorTableHandle) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Test(org.testng.annotations.Test)

Aggregations

RaptorTableHandle (io.trino.plugin.raptor.legacy.RaptorTableHandle)15 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)15 Test (org.testng.annotations.Test)15 ConnectorTableMetadata (io.trino.spi.connector.ConnectorTableMetadata)8 RaptorColumnHandle (io.trino.plugin.raptor.legacy.RaptorColumnHandle)4 ColumnHandle (io.trino.spi.connector.ColumnHandle)4 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)2 RaptorPartitioningHandle (io.trino.plugin.raptor.legacy.RaptorPartitioningHandle)1 TrinoException (io.trino.spi.TrinoException)1 ConnectorOutputTableHandle (io.trino.spi.connector.ConnectorOutputTableHandle)1 ConnectorTableLayout (io.trino.spi.connector.ConnectorTableLayout)1 SchemaTableName (io.trino.spi.connector.SchemaTableName)1