use of com.facebook.presto.spi.ConnectorOutputTableHandle in project presto by prestodb.
the class MetadataManager method beginCreateTable.
@Override
public OutputTableHandle beginCreateTable(Session session, String catalogName, ConnectorTableMetadata tableMetadata, Optional<NewTableLayout> layout) {
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorId connectorId = catalogMetadata.getConnectorId();
ConnectorMetadata metadata = catalogMetadata.getMetadata();
ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(connectorId);
ConnectorSession connectorSession = session.toConnectorSession(connectorId);
ConnectorOutputTableHandle handle = metadata.beginCreateTable(connectorSession, tableMetadata, layout.map(NewTableLayout::getLayout));
return new OutputTableHandle(connectorId, transactionHandle, handle);
}
use of com.facebook.presto.spi.ConnectorOutputTableHandle in project presto by prestodb.
the class AbstractTestHiveClient method createDummyTable.
private void createDummyTable(SchemaTableName tableName) {
try (Transaction transaction = newTransaction()) {
ConnectorSession session = newSession();
ConnectorMetadata metadata = transaction.getMetadata();
List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata("dummy", createUnboundedVarcharType()));
ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(tableName, columns, createTableProperties(TEXTFILE));
ConnectorOutputTableHandle handle = metadata.beginCreateTable(session, tableMetadata, Optional.empty());
metadata.finishCreateTable(session, handle, ImmutableList.of(), ImmutableList.of());
transaction.commit();
}
}
use of com.facebook.presto.spi.ConnectorOutputTableHandle in project presto by prestodb.
the class TestRaptorMetadata method testTransactionAbort.
@Test
public void testTransactionAbort() {
// start table creation
long transactionId = 1;
ConnectorOutputTableHandle outputHandle = metadata.beginCreateTable(SESSION, getOrdersTable(), Optional.empty());
// transaction is in progress
assertTrue(transactionExists(transactionId));
assertNull(transactionSuccessful(transactionId));
// force transaction to abort
shardManager.rollbackTransaction(transactionId);
assertTrue(transactionExists(transactionId));
assertFalse(transactionSuccessful(transactionId));
// commit table creation
try {
metadata.finishCreateTable(SESSION, outputHandle, ImmutableList.of(), ImmutableList.of());
fail("expected exception");
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), TRANSACTION_CONFLICT.toErrorCode());
}
}
Aggregations