Search in sources :

Example 51 with ConnectorId

use of com.facebook.presto.connector.ConnectorId 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 52 with ConnectorId

use of com.facebook.presto.connector.ConnectorId 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 53 with ConnectorId

use of com.facebook.presto.connector.ConnectorId 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)

Example 54 with ConnectorId

use of com.facebook.presto.connector.ConnectorId in project presto by prestodb.

the class MetadataManager method getColumnMetadata.

@Override
public ColumnMetadata getColumnMetadata(Session session, TableHandle tableHandle, ColumnHandle columnHandle) {
    requireNonNull(tableHandle, "tableHandle is null");
    requireNonNull(columnHandle, "columnHandle is null");
    ConnectorId connectorId = tableHandle.getConnectorId();
    ConnectorMetadata metadata = getMetadata(session, connectorId);
    return metadata.getColumnMetadata(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(), columnHandle);
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 55 with ConnectorId

use of com.facebook.presto.connector.ConnectorId in project presto by prestodb.

the class MetadataManager method renameSchema.

@Override
public void renameSchema(Session session, CatalogSchemaName source, String target) {
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, source.getCatalogName());
    ConnectorId connectorId = catalogMetadata.getConnectorId();
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    metadata.renameSchema(session.toConnectorSession(connectorId), source.getSchemaName(), target);
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Aggregations

ConnectorId (com.facebook.presto.connector.ConnectorId)76 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)39 ConnectorSession (com.facebook.presto.spi.ConnectorSession)14 Session (com.facebook.presto.Session)12 PrestoException (com.facebook.presto.spi.PrestoException)9 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)7 Test (org.testng.annotations.Test)7 ConnectorId.createInformationSchemaConnectorId (com.facebook.presto.connector.ConnectorId.createInformationSchemaConnectorId)5 ConnectorId.createSystemTablesConnectorId (com.facebook.presto.connector.ConnectorId.createSystemTablesConnectorId)5 TableHandle (com.facebook.presto.metadata.TableHandle)5 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)5 SchemaTableName (com.facebook.presto.spi.SchemaTableName)5 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)5 ImmutableList (com.google.common.collect.ImmutableList)5 QualifiedObjectName (com.facebook.presto.metadata.QualifiedObjectName)4 QualifiedObjectName.convertFromSchemaTableName (com.facebook.presto.metadata.QualifiedObjectName.convertFromSchemaTableName)4 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)4 ConnectorInsertTableHandle (com.facebook.presto.spi.ConnectorInsertTableHandle)4 SemanticException (com.facebook.presto.sql.analyzer.SemanticException)4 TransactionManager (com.facebook.presto.transaction.TransactionManager)4