use of io.trino.spi.connector.ConnectorSession 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.ConnectorSession 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.ConnectorSession in project trino by trinodb.
the class MetadataManager method getViewInternal.
private Optional<ConnectorViewDefinition> getViewInternal(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.getView(connectorSession, viewName.asSchemaTableName());
}
return Optional.empty();
}
use of io.trino.spi.connector.ConnectorSession in project trino by trinodb.
the class DynamicFilterService method getDynamicFilteringStats.
public DynamicFiltersStats getDynamicFilteringStats(QueryId queryId, Session session) {
DynamicFilterContext context = dynamicFilterContexts.get(queryId);
if (context == null) {
// query has been removed or dynamic filtering is not enabled
return DynamicFiltersStats.EMPTY;
}
int lazyFilters = context.getLazyDynamicFilters().size();
int replicatedFilters = context.getReplicatedDynamicFilters().size();
int totalDynamicFilters = context.getTotalDynamicFilters();
ConnectorSession connectorSession = session.toConnectorSession();
List<DynamicFilterDomainStats> dynamicFilterDomainStats = context.getDynamicFilterSummaries().entrySet().stream().map(entry -> {
DynamicFilterId dynamicFilterId = entry.getKey();
return new DynamicFilterDomainStats(dynamicFilterId, // use small limit for readability
entry.getValue().toString(connectorSession, 2), context.getDynamicFilterCollectionDuration(dynamicFilterId));
}).collect(toImmutableList());
return new DynamicFiltersStats(dynamicFilterDomainStats, lazyFilters, replicatedFilters, totalDynamicFilters, dynamicFilterDomainStats.size());
}
use of io.trino.spi.connector.ConnectorSession in project trino by trinodb.
the class HiveMetadata method listTables.
private List<SchemaTableName> listTables(ConnectorSession session, SchemaTablePrefix prefix) {
if (prefix.getSchema().map(HiveUtil::isHiveSystemSchema).orElse(false)) {
return ImmutableList.of();
}
if (prefix.getTable().isEmpty()) {
return listTables(session, prefix.getSchema());
}
SchemaTableName tableName = prefix.toSchemaTableName();
Optional<Table> optionalTable;
try {
optionalTable = metastore.getTable(tableName.getSchemaName(), tableName.getTableName());
} catch (HiveViewNotSupportedException e) {
// exists, would be returned by listTables from schema
return ImmutableList.of(tableName);
}
return optionalTable.filter(table -> !hideDeltaLakeTables || !isDeltaLakeTable(table)).map(table -> ImmutableList.of(tableName)).orElseGet(ImmutableList::of);
}
Aggregations