use of io.prestosql.spi.connector.CatalogName in project hetu-core by openlookeng.
the class MetadataManager method applyFilter.
@Override
public Optional<ConstraintApplicationResult<TableHandle>> applyFilter(Session session, TableHandle table, Constraint constraint, List<Constraint> disjunctConstraints, Set<ColumnHandle> allColumnHandles, boolean pushPartitionsOnly) {
CatalogName catalogName = table.getCatalogName();
ConnectorMetadata metadata = getMetadata(session, catalogName);
if (metadata.usesLegacyTableLayouts()) {
return Optional.empty();
}
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.applyFilter(connectorSession, table.getConnectorHandle(), constraint, disjunctConstraints, allColumnHandles, pushPartitionsOnly).map(result -> new ConstraintApplicationResult<>(new TableHandle(catalogName, result.getHandle(), table.getTransaction(), Optional.empty()), result.getRemainingFilter()));
}
use of io.prestosql.spi.connector.CatalogName 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.CatalogName 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.CatalogName 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.CatalogName 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());
}
Aggregations