use of io.trino.spi.connector.ConnectorOutputTableHandle in project trino by trinodb.
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
assertTrinoExceptionThrownBy(() -> metadata.finishCreateTable(SESSION, outputHandle, ImmutableList.of(), ImmutableList.of())).hasErrorCode(TRANSACTION_CONFLICT).hasMessage("Transaction commit failed. Please retry the operation.");
}
use of io.trino.spi.connector.ConnectorOutputTableHandle in project trino by trinodb.
the class BlackHoleMetadata method createTable.
@Override
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, boolean ignoreExisting) {
ConnectorOutputTableHandle outputTableHandle = beginCreateTable(session, tableMetadata, Optional.empty());
finishCreateTable(session, outputTableHandle, ImmutableList.of(), ImmutableList.of());
}
use of io.trino.spi.connector.ConnectorOutputTableHandle in project trino by trinodb.
the class TestBlackHoleMetadata method tableIsCreatedAfterCommits.
@Test
public void tableIsCreatedAfterCommits() {
assertThatNoTableIsCreated();
SchemaTableName schemaTableName = new SchemaTableName("default", "temp_table");
ConnectorOutputTableHandle table = metadata.beginCreateTable(SESSION, new ConnectorTableMetadata(schemaTableName, ImmutableList.of(), tableProperties), Optional.empty());
assertThatNoTableIsCreated();
metadata.finishCreateTable(SESSION, table, ImmutableList.of(), ImmutableList.of());
List<SchemaTableName> tables = metadata.listTables(SESSION, Optional.empty());
assertEquals(tables.size(), 1, "Expected only one table.");
assertEquals(tables.get(0).getTableName(), "temp_table", "Expected table with name 'temp_table'");
}
use of io.trino.spi.connector.ConnectorOutputTableHandle in project trino by trinodb.
the class TestTableWriterOperator method createTableWriterOperator.
private Operator createTableWriterOperator(PageSinkManager pageSinkManager, OperatorFactory statisticsAggregation, List<Type> outputTypes, Session session, DriverContext driverContext) {
List<String> notNullColumnNames = new ArrayList<>(1);
notNullColumnNames.add(null);
TableWriterOperatorFactory factory = new TableWriterOperatorFactory(0, new PlanNodeId("test"), pageSinkManager, new CreateTarget(new OutputTableHandle(CONNECTOR_ID, new ConnectorTransactionHandle() {
}, new ConnectorOutputTableHandle() {
}), new SchemaTableName("testSchema", "testTable")), ImmutableList.of(0), notNullColumnNames, session, statisticsAggregation, outputTypes);
return factory.createOperator(driverContext);
}
use of io.trino.spi.connector.ConnectorOutputTableHandle in project trino by trinodb.
the class MetadataManager method beginCreateTable.
@Override
public OutputTableHandle beginCreateTable(Session session, String catalogName, ConnectorTableMetadata tableMetadata, Optional<TableLayout> layout) {
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
CatalogName catalog = catalogMetadata.getCatalogName();
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalog);
ConnectorSession connectorSession = session.toConnectorSession(catalog);
ConnectorOutputTableHandle handle = metadata.beginCreateTable(connectorSession, tableMetadata, layout.map(TableLayout::getLayout), getRetryPolicy(session).getRetryMode());
// TODO this should happen after finish but there is no way to get table name in finish step
if (catalogMetadata.getSecurityManagement() == SecurityManagement.SYSTEM) {
systemSecurityMetadata.tableCreated(session, new CatalogSchemaTableName(catalogName, tableMetadata.getTable()));
}
return new OutputTableHandle(catalog, transactionHandle, handle);
}
Aggregations