use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method getSchemaProperties.
@Override
public Map<String, Object> getSchemaProperties(Session session, CatalogSchemaName schemaName) {
if (!schemaExists(session, schemaName)) {
throw new TrinoException(SCHEMA_NOT_FOUND, format("Schema '%s' does not exist", schemaName));
}
CatalogMetadata catalogMetadata = getCatalogMetadata(session, new CatalogName(schemaName.getCatalogName()));
CatalogName catalogName = catalogMetadata.getConnectorIdForSchema(schemaName);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.getSchemaProperties(connectorSession, schemaName);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method getMaterializedViewInternal.
private Optional<ConnectorMaterializedViewDefinition> getMaterializedViewInternal(Session session, QualifiedObjectName viewName) {
if (viewName.getCatalogName().isEmpty() || viewName.getSchemaName().isEmpty() || viewName.getObjectName().isEmpty()) {
// View cannot exist
return Optional.empty();
}
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, viewName.getCatalogName());
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
CatalogName catalogName = catalogMetadata.getConnectorId(session, viewName);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
return metadata.getMaterializedView(connectorSession, viewName.asSchemaTableName());
}
return Optional.empty();
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method dropTable.
@Override
public void dropTable(Session session, TableHandle tableHandle) {
CatalogName catalogName = tableHandle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
Optional<CatalogSchemaTableName> tableName = getTableNameIfSystemSecurity(session, catalogMetadata, tableHandle);
metadata.dropTable(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
tableName.ifPresent(name -> systemSecurityMetadata.tableDropped(session, name));
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method listMaterializedViews.
@Override
public List<QualifiedObjectName> listMaterializedViews(Session session, QualifiedTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
Optional<QualifiedObjectName> objectName = prefix.asQualifiedObjectName();
if (objectName.isPresent()) {
return isMaterializedView(session, objectName.get()) ? ImmutableList.of(objectName.get()) : ImmutableList.of();
}
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
Set<QualifiedObjectName> materializedViews = new LinkedHashSet<>();
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
for (CatalogName catalogName : catalogMetadata.listConnectorIds()) {
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
metadata.listMaterializedViews(connectorSession, prefix.getSchemaName()).stream().map(convertFromSchemaTableName(prefix.getCatalogName())).filter(prefix::matches).forEach(materializedViews::add);
}
}
return ImmutableList.copyOf(materializedViews);
}
use of io.trino.spi.connector.ConnectorMetadata in project trino by trinodb.
the class MetadataManager method getSystemTable.
@Override
public Optional<SystemTable> getSystemTable(Session session, QualifiedObjectName tableName) {
requireNonNull(session, "session is null");
requireNonNull(tableName, "tableName is null");
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, tableName.getCatalogName());
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
// we query only main connector for runtime system tables
CatalogName catalogName = catalogMetadata.getCatalogName();
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
return metadata.getSystemTable(session.toConnectorSession(catalogName), tableName.asSchemaTableName());
}
return Optional.empty();
}
Aggregations