use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method getInfo.
@Override
public Optional<Object> getInfo(Session session, TableHandle handle) {
CatalogName catalogName = handle.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
if (usesLegacyTableLayouts(session, handle)) {
ConnectorTableLayoutHandle layoutHandle = handle.getLayout().orElseGet(() -> getLayout(session, handle, Constraint.alwaysTrue(), Optional.empty()).get().getNewTableHandle().getLayout().get());
return metadata.getInfo(layoutHandle);
}
return metadata.getInfo(handle.getConnectorHandle());
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method getViews.
@Override
public Map<QualifiedObjectName, ConnectorViewDefinition> getViews(Session session, QualifiedTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
Map<QualifiedObjectName, ConnectorViewDefinition> views = new LinkedHashMap<>();
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
SchemaTablePrefix tablePrefix = prefix.asSchemaTablePrefix();
for (CatalogName catalogName : catalogMetadata.listConnectorIds()) {
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
Map<SchemaTableName, ConnectorViewDefinition> viewMap;
if (tablePrefix.getTable().isPresent()) {
viewMap = metadata.getView(connectorSession, tablePrefix.toSchemaTableName()).map(view -> ImmutableMap.of(tablePrefix.toSchemaTableName(), view)).orElse(ImmutableMap.of());
} else {
viewMap = metadata.getViews(connectorSession, tablePrefix.getSchema());
}
for (Entry<SchemaTableName, ConnectorViewDefinition> entry : viewMap.entrySet()) {
QualifiedObjectName viewName = new QualifiedObjectName(prefix.getCatalogName(), entry.getKey().getSchemaName(), entry.getKey().getTableName());
views.put(viewName, entry.getValue());
}
}
}
return ImmutableMap.copyOf(views);
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method getTableLastModifiedTimeSupplier.
//
// Functions
//
@Override
public LongSupplier getTableLastModifiedTimeSupplier(Session session, TableHandle tableHandle) {
CatalogName catalogName = getTableMetadata(session, tableHandle).getCatalogName();
ConnectorMetadata connectorMetadata = getMetadata(session, catalogName);
long modificationTime = connectorMetadata.getTableModificationTime(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
return () -> modificationTime;
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method listSchemaNames.
@Override
public List<String> listSchemaNames(Session session, String catalogName) {
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, catalogName);
ImmutableSet.Builder<String> schemaNames = ImmutableSet.builder();
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
ConnectorSession connectorSession = session.toConnectorSession(catalogMetadata.getCatalogName());
for (CatalogName connectorId : catalogMetadata.listConnectorIds()) {
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
metadata.listSchemaNames(connectorSession).stream().map(schema -> schema.toLowerCase(Locale.ENGLISH)).forEach(schemaNames::add);
}
}
return ImmutableList.copyOf(schemaNames.build());
}
use of io.prestosql.spi.connector.ConnectorMetadata in project hetu-core by openlookeng.
the class MetadataManager method getColumnMetadata.
@Override
public ColumnMetadata getColumnMetadata(Session session, TableHandle tableHandle, ColumnHandle columnHandle) {
requireNonNull(tableHandle, "tableHandle is null");
requireNonNull(columnHandle, "columnHandle is null");
CatalogName catalogName = tableHandle.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
return metadata.getColumnMetadata(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), columnHandle);
}
Aggregations