Search in sources :

Example 61 with ConnectorMetadata

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

the class MetadataManager method finishDelete.

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

Example 62 with ConnectorMetadata

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

the class MetadataManager method dropTable.

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

Example 63 with ConnectorMetadata

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

the class MetadataManager method getColumnHandles.

@Override
public Map<String, ColumnHandle> getColumnHandles(Session session, TableHandle tableHandle) {
    ConnectorId connectorId = tableHandle.getConnectorId();
    ConnectorMetadata metadata = getMetadata(session, connectorId);
    Map<String, ColumnHandle> handles = metadata.getColumnHandles(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle());
    ImmutableMap.Builder<String, ColumnHandle> map = ImmutableMap.builder();
    for (Entry<String, ColumnHandle> mapEntry : handles.entrySet()) {
        map.put(mapEntry.getKey().toLowerCase(ENGLISH), mapEntry.getValue());
    }
    return map.build();
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ImmutableMap(com.google.common.collect.ImmutableMap) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 64 with ConnectorMetadata

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

the class MetadataManager method getInfo.

@Override
public Optional<Object> getInfo(Session session, TableLayoutHandle handle) {
    ConnectorId connectorId = handle.getConnectorId();
    ConnectorMetadata metadata = getMetadata(session, connectorId);
    ConnectorTableLayout tableLayout = metadata.getTableLayout(session.toConnectorSession(connectorId), handle.getConnectorHandle());
    return metadata.getInfo(tableLayout.getHandle());
}
Also used : ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 65 with ConnectorMetadata

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

the class MetadataManager method listTables.

@Override
public List<QualifiedObjectName> listTables(Session session, QualifiedTablePrefix prefix) {
    requireNonNull(prefix, "prefix is null");
    Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
    Set<QualifiedObjectName> tables = new LinkedHashSet<>();
    if (catalog.isPresent()) {
        CatalogMetadata catalogMetadata = catalog.get();
        String schemaNameOrNull = prefix.getSchemaName().orElse(null);
        for (ConnectorId connectorId : catalogMetadata.listConnectorIds()) {
            ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
            ConnectorSession connectorSession = session.toConnectorSession(connectorId);
            metadata.listTables(connectorSession, schemaNameOrNull).stream().map(convertFromSchemaTableName(prefix.getCatalogName())::apply).forEach(tables::add);
        }
    }
    return ImmutableList.copyOf(tables);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ConnectorSession(com.facebook.presto.spi.ConnectorSession) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) 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