Search in sources :

Example 1 with InsertTableHandle

use of com.facebook.presto.metadata.InsertTableHandle in project presto by prestodb.

the class TestHiveIntegrationSmokeTest method getHiveInsertTableHandle.

private HiveInsertTableHandle getHiveInsertTableHandle(Session session, String tableName) {
    Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata();
    return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl()).execute(session, transactionSession -> {
        QualifiedObjectName objectName = new QualifiedObjectName(catalog, TPCH_SCHEMA, tableName);
        Optional<TableHandle> handle = metadata.getTableHandle(transactionSession, objectName);
        InsertTableHandle insertTableHandle = metadata.beginInsert(transactionSession, handle.get());
        HiveInsertTableHandle hiveInsertTableHandle = (HiveInsertTableHandle) insertTableHandle.getConnectorHandle();
        metadata.finishInsert(transactionSession, insertTableHandle, ImmutableList.of(), ImmutableList.of());
        return hiveInsertTableHandle;
    });
}
Also used : Metadata(com.facebook.presto.metadata.Metadata) TableMetadata(com.facebook.presto.metadata.TableMetadata) ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) InsertTableHandle(com.facebook.presto.metadata.InsertTableHandle) TableHandle(com.facebook.presto.spi.TableHandle) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName) InsertTableHandle(com.facebook.presto.metadata.InsertTableHandle)

Aggregations

QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)1 InsertTableHandle (com.facebook.presto.metadata.InsertTableHandle)1 Metadata (com.facebook.presto.metadata.Metadata)1 TableMetadata (com.facebook.presto.metadata.TableMetadata)1 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 TableHandle (com.facebook.presto.spi.TableHandle)1