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();
}
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);
}
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));
}
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);
}
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);
}
Aggregations