use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method listTablePrivileges.
@Override
public List<GrantInfo> listTablePrivileges(Session session, QualifiedTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
ImmutableSet.Builder<GrantInfo> grantInfos = ImmutableSet.builder();
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
ConnectorSession connectorSession = session.toConnectorSession(catalogMetadata.getCatalogName());
List<CatalogName> connectorIds = prefix.asQualifiedObjectName().map(qualifiedTableName -> singletonList(catalogMetadata.getConnectorId(session, qualifiedTableName))).orElseGet(catalogMetadata::listConnectorIds);
for (CatalogName catalogName : connectorIds) {
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(catalogName);
grantInfos.addAll(metadata.listTablePrivileges(connectorSession, prefix.asSchemaTablePrefix()));
}
}
return ImmutableList.copyOf(grantInfos.build());
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method resetInsertForRerun.
/**
* Snapshot: Remove any previous changes from previous execution attempt, to prepare for query resume
*/
@Override
public void resetInsertForRerun(Session session, InsertTableHandle tableHandle, OptionalLong snapshotIndex) {
ConnectorMetadata metadata = getMetadata(session, tableHandle.getCatalogName());
metadata.resetInsertForRerun(session.toConnectorSession(tableHandle.getCatalogName()), tableHandle.getConnectorHandle(), snapshotIndex);
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method executeDelete.
@Override
public OptionalLong executeDelete(Session session, TableHandle table) {
CatalogName catalogName = table.getCatalogName();
ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
if (metadata.usesLegacyTableLayouts()) {
checkArgument(table.getLayout().isPresent(), "table layout is missing");
return metadata.metadataDelete(session.toConnectorSession(catalogName), table.getConnectorHandle(), table.getLayout().get());
}
checkArgument(!table.getLayout().isPresent(), "table layout should not be present");
return metadata.executeDelete(connectorSession, table.getConnectorHandle());
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method getTableMetadata.
@Override
public TableMetadata getTableMetadata(Session session, TableHandle tableHandle) {
CatalogName catalogName = tableHandle.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
ConnectorTableMetadata tableMetadata = metadata.getTableMetadata(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
if (tableMetadata.getColumns().isEmpty()) {
throw new PrestoException(NOT_SUPPORTED, "Table has no columns: " + tableHandle);
}
return new TableMetadata(catalogName, tableMetadata);
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method createRole.
//
// Roles and Grants
//
@Override
public void createRole(Session session, String role, Optional<PrestoPrincipal> grantor, String catalog) {
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalog);
CatalogName catalogName = catalogMetadata.getCatalogName();
ConnectorMetadata metadata = catalogMetadata.getMetadata();
metadata.createRole(session.toConnectorSession(catalogName), role, grantor);
}
Aggregations