use of io.trino.spi.connector.ConnectorSession in project trino by trinodb.
the class MetadataManager method applyDelete.
@Override
public Optional<TableHandle> applyDelete(Session session, TableHandle table) {
CatalogName catalogName = table.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.applyDelete(connectorSession, table.getConnectorHandle()).map(newHandle -> new TableHandle(catalogName, newHandle, table.getTransaction()));
}
use of io.trino.spi.connector.ConnectorSession in project trino by trinodb.
the class MetadataManager method listTables.
@Override
public List<QualifiedObjectName> listTables(Session session, QualifiedTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
Optional<QualifiedObjectName> objectName = prefix.asQualifiedObjectName();
if (objectName.isPresent()) {
Optional<Boolean> exists = isExistingRelationForListing(session, objectName.get());
if (exists.isPresent()) {
return exists.get() ? ImmutableList.of(objectName.get()) : ImmutableList.of();
}
}
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
Set<QualifiedObjectName> tables = new LinkedHashSet<>();
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
for (CatalogName catalogName : catalogMetadata.listConnectorIds()) {
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
metadata.listTables(connectorSession, prefix.getSchemaName()).stream().map(convertFromSchemaTableName(prefix.getCatalogName())).filter(prefix::matches).forEach(tables::add);
}
}
return ImmutableList.copyOf(tables);
}
use of io.trino.spi.connector.ConnectorSession in project trino by trinodb.
the class MetadataManager method applyTableScanRedirect.
@Override
public Optional<TableScanRedirectApplicationResult> applyTableScanRedirect(Session session, TableHandle tableHandle) {
CatalogName catalogName = tableHandle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.applyTableScanRedirect(connectorSession, tableHandle.getConnectorHandle());
}
use of io.trino.spi.connector.ConnectorSession 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.ConnectorSession 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));
}
Aggregations