use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method grantSchemaPrivileges.
@Override
public void grantSchemaPrivileges(Session session, CatalogSchemaName schemaName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) {
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, schemaName.getCatalogName());
if (catalogMetadata.getSecurityManagement() == SecurityManagement.SYSTEM) {
systemSecurityMetadata.grantSchemaPrivileges(session, schemaName, privileges, grantee, grantOption);
return;
}
CatalogName catalogName = catalogMetadata.getCatalogName();
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
metadata.grantSchemaPrivileges(session.toConnectorSession(catalogName), schemaName.getSchemaName(), privileges, grantee, grantOption);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method setTableComment.
@Override
public void setTableComment(Session session, TableHandle tableHandle, Optional<String> comment) {
CatalogName catalogName = tableHandle.getCatalogName();
ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
metadata.setTableComment(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), comment);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method getMaterializedViews.
@Override
public Map<QualifiedObjectName, ViewInfo> getMaterializedViews(Session session, QualifiedTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
Map<QualifiedObjectName, ViewInfo> views = new LinkedHashMap<>();
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
SchemaTablePrefix tablePrefix = prefix.asSchemaTablePrefix();
for (CatalogName catalogName : catalogMetadata.listConnectorIds()) {
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
Map<SchemaTableName, ConnectorMaterializedViewDefinition> materializedViewMap;
if (tablePrefix.getTable().isPresent()) {
materializedViewMap = metadata.getMaterializedView(connectorSession, tablePrefix.toSchemaTableName()).map(view -> ImmutableMap.of(tablePrefix.toSchemaTableName(), view)).orElse(ImmutableMap.of());
} else {
materializedViewMap = metadata.getMaterializedViews(connectorSession, tablePrefix.getSchema());
}
for (Entry<SchemaTableName, ConnectorMaterializedViewDefinition> entry : materializedViewMap.entrySet()) {
QualifiedObjectName viewName = new QualifiedObjectName(prefix.getCatalogName(), entry.getKey().getSchemaName(), entry.getKey().getTableName());
views.put(viewName, new ViewInfo(entry.getValue()));
}
}
}
return ImmutableMap.copyOf(views);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method getMaterializedViewFreshness.
@Override
public MaterializedViewFreshness getMaterializedViewFreshness(Session session, QualifiedObjectName viewName) {
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, viewName.getCatalogName());
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
CatalogName catalogName = catalogMetadata.getConnectorId(session, viewName);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.getMaterializedViewFreshness(connectorSession, viewName.asSchemaTableName());
}
return new MaterializedViewFreshness(false);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method truncateTable.
@Override
public void truncateTable(Session session, TableHandle tableHandle) {
CatalogName catalogName = tableHandle.getCatalogName();
ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
metadata.truncateTable(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
}
Aggregations