Search in sources :

Example 16 with ConnectorMetadata

use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.

the class MetadataManager method getTableHandleForStatisticsCollection.

@Override
public Optional<TableHandle> getTableHandleForStatisticsCollection(Session session, QualifiedObjectName table, Map<String, Object> analyzeProperties) {
    requireNonNull(table, "table is null");
    Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, table.getCatalogName());
    if (catalog.isPresent()) {
        CatalogMetadata catalogMetadata = catalog.get();
        CatalogName catalogName = catalogMetadata.getConnectorId(session, table);
        ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
        ConnectorTableHandle tableHandle = metadata.getTableHandleForStatisticsCollection(session.toConnectorSession(catalogName), table.asSchemaTableName(), analyzeProperties);
        if (tableHandle != null) {
            return Optional.of(new TableHandle(catalogName, tableHandle, catalogMetadata.getTransactionHandleFor(catalogName)));
        }
    }
    return Optional.empty();
}
Also used : CatalogName(io.trino.connector.CatalogName) ConnectorOutputTableHandle(io.trino.spi.connector.ConnectorOutputTableHandle) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) ConnectorInsertTableHandle(io.trino.spi.connector.ConnectorInsertTableHandle) ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle)

Example 17 with ConnectorMetadata

use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.

the class MetadataManager method listApplicableRoles.

@Override
public Set<RoleGrant> listApplicableRoles(Session session, TrinoPrincipal principal, Optional<String> catalog) {
    if (catalog.isPresent()) {
        Optional<CatalogMetadata> catalogMetadata = getOptionalCatalogMetadata(session, catalog.get());
        if (catalogMetadata.isEmpty()) {
            return ImmutableSet.of();
        }
        // instead of returning nothing, so information schema role tables will work properly
        if (catalogMetadata.get().getSecurityManagement() == SecurityManagement.CONNECTOR) {
            CatalogName catalogName = catalogMetadata.get().getCatalogName();
            ConnectorSession connectorSession = session.toConnectorSession(catalogName);
            ConnectorMetadata metadata = catalogMetadata.get().getMetadataFor(session, catalogName);
            return ImmutableSet.copyOf(metadata.listApplicableRoles(connectorSession, principal));
        }
    }
    return systemSecurityMetadata.listApplicableRoles(session, principal);
}
Also used : CatalogName(io.trino.connector.CatalogName) ConnectorSession(io.trino.spi.connector.ConnectorSession) ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata)

Example 18 with ConnectorMetadata

use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.

the class MetadataManager method listEnabledRoles.

@Override
public Set<String> listEnabledRoles(Session session, String catalog) {
    Optional<CatalogMetadata> catalogMetadata = getOptionalCatalogMetadata(session, catalog);
    if (catalogMetadata.isEmpty()) {
        return ImmutableSet.of();
    }
    // instead of returning nothing, so information schema role tables will work properly
    if (catalogMetadata.get().getSecurityManagement() == SecurityManagement.SYSTEM) {
        return systemSecurityMetadata.listEnabledRoles(session.getIdentity());
    }
    CatalogName catalogName = catalogMetadata.get().getCatalogName();
    ConnectorSession connectorSession = session.toConnectorSession(catalogName);
    ConnectorMetadata metadata = catalogMetadata.get().getMetadataFor(session, catalogName);
    return ImmutableSet.copyOf(metadata.listEnabledRoles(connectorSession));
}
Also used : CatalogName(io.trino.connector.CatalogName) ConnectorSession(io.trino.spi.connector.ConnectorSession) ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata)

Example 19 with ConnectorMetadata

use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.

the class MetadataManager method beginStatisticsCollection.

@Override
public AnalyzeTableHandle beginStatisticsCollection(Session session, TableHandle tableHandle) {
    CatalogName catalogName = tableHandle.getCatalogName();
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
    ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
    ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogName);
    ConnectorTableHandle connectorTableHandle = metadata.beginStatisticsCollection(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
    return new AnalyzeTableHandle(catalogName, transactionHandle, connectorTableHandle);
}
Also used : ConnectorTransactionHandle(io.trino.spi.connector.ConnectorTransactionHandle) CatalogName(io.trino.connector.CatalogName) ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle)

Example 20 with ConnectorMetadata

use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.

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");
    CatalogName catalogName = tableHandle.getCatalogName();
    ConnectorMetadata metadata = getMetadata(session, catalogName);
    return metadata.getColumnMetadata(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), columnHandle);
}
Also used : CatalogName(io.trino.connector.CatalogName) ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata)

Aggregations

ConnectorMetadata (io.trino.spi.connector.ConnectorMetadata)190 CatalogName (io.trino.connector.CatalogName)101 ConnectorSession (io.trino.spi.connector.ConnectorSession)97 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)70 Test (org.testng.annotations.Test)63 TestingConnectorSession (io.trino.testing.TestingConnectorSession)52 SchemaTableName (io.trino.spi.connector.SchemaTableName)48 CatalogSchemaTableName (io.trino.spi.connector.CatalogSchemaTableName)43 ColumnHandle (io.trino.spi.connector.ColumnHandle)40 ConnectorOutputTableHandle (io.trino.spi.connector.ConnectorOutputTableHandle)32 ConnectorTableMetadata (io.trino.spi.connector.ConnectorTableMetadata)32 ConnectorInsertTableHandle (io.trino.spi.connector.ConnectorInsertTableHandle)31 Constraint (io.trino.spi.connector.Constraint)31 MaterializedResult (io.trino.testing.MaterializedResult)27 HiveColumnHandle.bucketColumnHandle (io.trino.plugin.hive.HiveColumnHandle.bucketColumnHandle)26 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)26 TrinoException (io.trino.spi.TrinoException)23 Slice (io.airlift.slice.Slice)22 ConnectorTransactionHandle (io.trino.spi.connector.ConnectorTransactionHandle)21 SchemaTablePrefix (io.trino.spi.connector.SchemaTablePrefix)20