Search in sources :

Example 16 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class MetadataManager method getInsertLayout.

@Override
public Optional<NewTableLayout> getInsertLayout(Session session, TableHandle table) {
    ConnectorId connectorId = table.getConnectorId();
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, connectorId);
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    Optional<ConnectorNewTableLayout> insertLayout = metadata.getInsertLayout(session.toConnectorSession(connectorId), table.getConnectorHandle());
    if (!insertLayout.isPresent()) {
        return Optional.empty();
    }
    return Optional.of(new NewTableLayout(connectorId, catalogMetadata.getTransactionHandleFor(connectorId), insertLayout.get()));
}
Also used : ConnectorNewTableLayout(com.facebook.presto.spi.ConnectorNewTableLayout) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorNewTableLayout(com.facebook.presto.spi.ConnectorNewTableLayout) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 17 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class MetadataManager method getViews.

@Override
public Map<QualifiedObjectName, ViewDefinition> getViews(Session session, QualifiedTablePrefix prefix) {
    requireNonNull(prefix, "prefix is null");
    Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
    Map<QualifiedObjectName, ViewDefinition> views = new LinkedHashMap<>();
    if (catalog.isPresent()) {
        CatalogMetadata catalogMetadata = catalog.get();
        SchemaTablePrefix tablePrefix = prefix.asSchemaTablePrefix();
        for (ConnectorId connectorId : catalogMetadata.listConnectorIds()) {
            ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
            ConnectorSession connectorSession = session.toConnectorSession(connectorId);
            for (Entry<SchemaTableName, ConnectorViewDefinition> entry : metadata.getViews(connectorSession, tablePrefix).entrySet()) {
                QualifiedObjectName viewName = new QualifiedObjectName(prefix.getCatalogName(), entry.getKey().getSchemaName(), entry.getKey().getTableName());
                views.put(viewName, deserializeView(entry.getValue().getViewData()));
            }
        }
    }
    return ImmutableMap.copyOf(views);
}
Also used : ConnectorViewDefinition(com.facebook.presto.spi.ConnectorViewDefinition) SchemaTablePrefix(com.facebook.presto.spi.SchemaTablePrefix) SchemaTableName(com.facebook.presto.spi.SchemaTableName) QualifiedObjectName.convertFromSchemaTableName(com.facebook.presto.metadata.QualifiedObjectName.convertFromSchemaTableName) LinkedHashMap(java.util.LinkedHashMap) ConnectorViewDefinition(com.facebook.presto.spi.ConnectorViewDefinition) ConnectorSession(com.facebook.presto.spi.ConnectorSession) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 18 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class MetadataManager method finishInsert.

@Override
public Optional<ConnectorOutputMetadata> finishInsert(Session session, InsertTableHandle tableHandle, Collection<Slice> fragments) {
    ConnectorId connectorId = tableHandle.getConnectorId();
    ConnectorMetadata metadata = getMetadata(session, connectorId);
    return metadata.finishInsert(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(), fragments);
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 19 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class MetadataManager method metadataDelete.

@Override
public OptionalLong metadataDelete(Session session, TableHandle tableHandle, TableLayoutHandle tableLayoutHandle) {
    ConnectorId connectorId = tableHandle.getConnectorId();
    ConnectorMetadata metadata = getMetadataForWrite(session, connectorId);
    return metadata.metadataDelete(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(), tableLayoutHandle.getConnectorHandle());
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 20 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class MetadataManager method beginInsert.

@Override
public InsertTableHandle beginInsert(Session session, TableHandle tableHandle) {
    ConnectorId connectorId = tableHandle.getConnectorId();
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, connectorId);
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(connectorId);
    ConnectorInsertTableHandle handle = metadata.beginInsert(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle());
    return new InsertTableHandle(tableHandle.getConnectorId(), transactionHandle, handle);
}
Also used : ConnectorInsertTableHandle(com.facebook.presto.spi.ConnectorInsertTableHandle) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorInsertTableHandle(com.facebook.presto.spi.ConnectorInsertTableHandle) ConnectorId(com.facebook.presto.connector.ConnectorId)

Aggregations

ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)100 ConnectorSession (com.facebook.presto.spi.ConnectorSession)49 Test (org.testng.annotations.Test)48 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)42 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)39 ConnectorId (com.facebook.presto.connector.ConnectorId)38 ColumnHandle (com.facebook.presto.spi.ColumnHandle)33 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)33 SchemaTableName (com.facebook.presto.spi.SchemaTableName)31 MaterializedResult (com.facebook.presto.testing.MaterializedResult)28 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)26 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)25 ConnectorInsertTableHandle (com.facebook.presto.spi.ConnectorInsertTableHandle)24 ConnectorPageSink (com.facebook.presto.spi.ConnectorPageSink)24 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)24 PrestoException (com.facebook.presto.spi.PrestoException)24 Path (org.apache.hadoop.fs.Path)24 Constraint (com.facebook.presto.spi.Constraint)23 SchemaTablePrefix (com.facebook.presto.spi.SchemaTablePrefix)23 MaterializedRow (com.facebook.presto.testing.MaterializedRow)23