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());
}
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"));
}
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);
}
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);
}
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));
}
Aggregations