use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.
the class MetadataManager method applySample.
@Override
public Optional<TableHandle> applySample(Session session, TableHandle table, SampleType sampleType, double sampleRatio) {
CatalogName catalogName = table.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
if (metadata.usesLegacyTableLayouts()) {
return Optional.empty();
}
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.applySample(connectorSession, table.getConnectorHandle(), sampleType, sampleRatio).map(result -> new TableHandle(catalogName, result, table.getTransaction(), Optional.empty()));
}
use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.
the class MetadataManager method listEnabledRoles.
@Override
public Set<String> listEnabledRoles(Session session, String catalog) {
Optional<CatalogMetadata> catalogMetadata = getOptionalCatalogMetadata(session, catalog);
if (!catalogMetadata.isPresent()) {
return ImmutableSet.of();
}
CatalogName catalogName = catalogMetadata.get().getCatalogName();
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
ConnectorMetadata metadata = catalogMetadata.get().getMetadataFor(catalogName);
return ImmutableSet.copyOf(metadata.listEnabledRoles(connectorSession));
}
use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.
the class MetadataManager method getNewTableLayout.
@Override
public Optional<NewTableLayout> getNewTableLayout(Session session, String catalogName, ConnectorTableMetadata tableMetadata) {
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
CatalogName catalog = catalogMetadata.getCatalogName();
ConnectorMetadata metadata = catalogMetadata.getMetadata();
ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalog);
ConnectorSession connectorSession = session.toConnectorSession(catalog);
return metadata.getNewTableLayout(connectorSession, tableMetadata).map(layout -> new NewTableLayout(catalog, transactionHandle, layout));
}
use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.
the class MetadataManager method listRoles.
@Override
public Set<String> listRoles(Session session, String catalog) {
Optional<CatalogMetadata> catalogMetadata = getOptionalCatalogMetadata(session, catalog);
if (!catalogMetadata.isPresent()) {
return ImmutableSet.of();
}
CatalogName catalogName = catalogMetadata.get().getCatalogName();
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
ConnectorMetadata metadata = catalogMetadata.get().getMetadataFor(catalogName);
return metadata.listRoles(connectorSession).stream().collect(toImmutableSet());
}
use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.
the class MetadataManager method getTableHandle.
@Override
public Optional<TableHandle> getTableHandle(Session session, QualifiedObjectName table) {
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(catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
ConnectorTableHandle tableHandle = metadata.getTableHandle(connectorSession, toSchemaTableName(table));
if (tableHandle != null) {
return Optional.of(new TableHandle(catalogName, tableHandle, catalogMetadata.getTransactionHandleFor(catalogName), Optional.empty()));
}
}
return Optional.empty();
}
Aggregations