use of com.facebook.presto.FullConnectorSession in project presto by prestodb.
the class InformationSchemaMetadata method calculatePrefixesWithSchemaName.
private Set<QualifiedTablePrefix> calculatePrefixesWithSchemaName(ConnectorSession connectorSession, TupleDomain<ColumnHandle> constraint, Optional<Predicate<Map<ColumnHandle, NullableValue>>> predicate) {
Optional<Set<String>> schemas = filterString(constraint, SCHEMA_COLUMN_HANDLE);
if (schemas.isPresent()) {
return schemas.get().stream().filter(this::isLowerCase).map(schema -> new QualifiedTablePrefix(catalogName, schema)).collect(toImmutableSet());
}
Session session = ((FullConnectorSession) connectorSession).getSession();
return metadata.listSchemaNames(session, catalogName).stream().filter(schema -> !predicate.isPresent() || predicate.get().test(schemaAsFixedValues(schema))).map(schema -> new QualifiedTablePrefix(catalogName, schema)).collect(toImmutableSet());
}
use of com.facebook.presto.FullConnectorSession in project presto by prestodb.
the class InformationSchemaMetadata method calculatePrefixesWithTableName.
public Set<QualifiedTablePrefix> calculatePrefixesWithTableName(ConnectorSession connectorSession, Set<QualifiedTablePrefix> prefixes, TupleDomain<ColumnHandle> constraint, Optional<Predicate<Map<ColumnHandle, NullableValue>>> predicate) {
Session session = ((FullConnectorSession) connectorSession).getSession();
Optional<Set<String>> tables = filterString(constraint, TABLE_NAME_COLUMN_HANDLE);
if (tables.isPresent()) {
return prefixes.stream().flatMap(prefix -> tables.get().stream().filter(this::isLowerCase).map(table -> table.toLowerCase(ENGLISH)).map(table -> new QualifiedObjectName(catalogName, prefix.getSchemaName().get(), table))).filter(objectName -> metadata.getTableHandle(session, objectName).isPresent() || metadata.getView(session, objectName).isPresent()).map(QualifiedTablePrefix::toQualifiedTablePrefix).collect(toImmutableSet());
}
return prefixes.stream().flatMap(prefix -> Stream.concat(metadata.listTables(session, prefix).stream(), metadata.listViews(session, prefix).stream())).filter(objectName -> !predicate.isPresent() || predicate.get().test(asFixedValues(objectName))).map(QualifiedTablePrefix::toQualifiedTablePrefix).collect(toImmutableSet());
}
use of com.facebook.presto.FullConnectorSession in project presto by prestodb.
the class InformationSchemaPageSourceProvider method getInternalTable.
private InternalTable getInternalTable(ConnectorSession connectorSession, ConnectorSplit connectorSplit, List<ColumnHandle> columns) {
Session session = ((FullConnectorSession) connectorSession).getSession();
InformationSchemaSplit split = (InformationSchemaSplit) connectorSplit;
requireNonNull(columns, "columns is null");
InformationSchemaTableHandle handle = split.getTableHandle();
Set<QualifiedTablePrefix> prefixes = split.getPrefixes();
return getInformationSchemaTable(session, handle.getCatalogName(), handle.getSchemaTableName(), prefixes);
}
Aggregations