use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method setViewAuthorization.
@Override
public void setViewAuthorization(Session session, CatalogSchemaTableName view, TrinoPrincipal principal) {
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, view.getCatalogName());
CatalogName catalogName = catalogMetadata.getCatalogName();
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
if (catalogMetadata.getSecurityManagement() == SecurityManagement.SYSTEM) {
systemSecurityMetadata.setViewOwner(session, view, principal);
} else {
metadata.setViewAuthorization(session.toConnectorSession(catalogName), view.getSchemaTableName(), principal);
}
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method setTableProperties.
@Override
public void setTableProperties(Session session, TableHandle tableHandle, Map<String, Optional<Object>> properties) {
CatalogName catalogName = tableHandle.getCatalogName();
ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
metadata.setTableProperties(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), properties);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method beginRefreshMaterializedView.
@Override
public InsertTableHandle beginRefreshMaterializedView(Session session, TableHandle tableHandle, List<TableHandle> sourceTableHandles) {
CatalogName catalogName = tableHandle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogName);
List<ConnectorTableHandle> sourceConnectorHandles = sourceTableHandles.stream().map(TableHandle::getConnectorHandle).collect(Collectors.toList());
sourceConnectorHandles.add(tableHandle.getConnectorHandle());
if (sourceConnectorHandles.stream().map(Object::getClass).distinct().count() > 1) {
throw new TrinoException(NOT_SUPPORTED, "Cross connector materialized views are not supported");
}
ConnectorInsertTableHandle handle = metadata.beginRefreshMaterializedView(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), sourceConnectorHandles, getRetryPolicy(session).getRetryMode());
return new InsertTableHandle(tableHandle.getCatalogName(), transactionHandle, handle);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method beginInsert.
@Override
public InsertTableHandle beginInsert(Session session, TableHandle tableHandle, List<ColumnHandle> columns) {
CatalogName catalogName = tableHandle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogName);
ConnectorInsertTableHandle handle = metadata.beginInsert(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), columns, getRetryPolicy(session).getRetryMode());
return new InsertTableHandle(tableHandle.getCatalogName(), transactionHandle, handle);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method applyProjection.
@Override
public Optional<ProjectionApplicationResult<TableHandle>> applyProjection(Session session, TableHandle table, List<ConnectorExpression> projections, Map<String, ColumnHandle> assignments) {
CatalogName catalogName = table.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.applyProjection(connectorSession, table.getConnectorHandle(), projections, assignments).map(result -> {
verifyProjection(table, result.getProjections(), result.getAssignments(), projections.size());
return new ProjectionApplicationResult<>(new TableHandle(catalogName, result.getHandle(), table.getTransaction()), result.getProjections(), result.getAssignments(), result.isPrecalculateStatistics());
});
}
Aggregations