Search in sources :

Example 1 with FullConnectorSession

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());
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) EquatableValueSet(com.facebook.presto.common.predicate.EquatableValueSet) Slice(io.airlift.slice.Slice) VarcharType.createUnboundedVarcharType(com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType) ConnectorTableLayoutHandle(com.facebook.presto.spi.ConnectorTableLayoutHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) FullConnectorSession(com.facebook.presto.FullConnectorSession) ENGLISH(java.util.Locale.ENGLISH) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) BIGINT(com.facebook.presto.common.type.BigintType.BIGINT) ImmutableSet(com.google.common.collect.ImmutableSet) NullableValue(com.facebook.presto.common.predicate.NullableValue) QualifiedTablePrefix(com.facebook.presto.metadata.QualifiedTablePrefix) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) Session(com.facebook.presto.Session) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) Collection(java.util.Collection) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) Constraint(com.facebook.presto.spi.Constraint) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Predicates.compose(com.google.common.base.Predicates.compose) Domain(com.facebook.presto.common.predicate.Domain) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) MetadataUtil.findColumnMetadata(com.facebook.presto.metadata.MetadataUtil.findColumnMetadata) ConnectorSession(com.facebook.presto.spi.ConnectorSession) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) List(java.util.List) ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) Stream(java.util.stream.Stream) SchemaTablePrefix(com.facebook.presto.spi.SchemaTablePrefix) ColumnHandle(com.facebook.presto.spi.ColumnHandle) SchemaMetadataBuilder.schemaMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.SchemaMetadataBuilder.schemaMetadataBuilder) Entry(java.util.Map.Entry) Function.identity(java.util.function.Function.identity) Optional(java.util.Optional) Metadata(com.facebook.presto.metadata.Metadata) EquatableValueSet(com.facebook.presto.common.predicate.EquatableValueSet) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) QualifiedTablePrefix(com.facebook.presto.metadata.QualifiedTablePrefix) FullConnectorSession(com.facebook.presto.FullConnectorSession) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession) FullConnectorSession(com.facebook.presto.FullConnectorSession)

Example 2 with FullConnectorSession

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());
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) EquatableValueSet(com.facebook.presto.common.predicate.EquatableValueSet) Slice(io.airlift.slice.Slice) VarcharType.createUnboundedVarcharType(com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType) ConnectorTableLayoutHandle(com.facebook.presto.spi.ConnectorTableLayoutHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) FullConnectorSession(com.facebook.presto.FullConnectorSession) ENGLISH(java.util.Locale.ENGLISH) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) BIGINT(com.facebook.presto.common.type.BigintType.BIGINT) ImmutableSet(com.google.common.collect.ImmutableSet) NullableValue(com.facebook.presto.common.predicate.NullableValue) QualifiedTablePrefix(com.facebook.presto.metadata.QualifiedTablePrefix) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) Session(com.facebook.presto.Session) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) Collection(java.util.Collection) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) Constraint(com.facebook.presto.spi.Constraint) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Predicates.compose(com.google.common.base.Predicates.compose) Domain(com.facebook.presto.common.predicate.Domain) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) MetadataUtil.findColumnMetadata(com.facebook.presto.metadata.MetadataUtil.findColumnMetadata) ConnectorSession(com.facebook.presto.spi.ConnectorSession) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) List(java.util.List) ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) Stream(java.util.stream.Stream) SchemaTablePrefix(com.facebook.presto.spi.SchemaTablePrefix) ColumnHandle(com.facebook.presto.spi.ColumnHandle) SchemaMetadataBuilder.schemaMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.SchemaMetadataBuilder.schemaMetadataBuilder) Entry(java.util.Map.Entry) Function.identity(java.util.function.Function.identity) Optional(java.util.Optional) Metadata(com.facebook.presto.metadata.Metadata) EquatableValueSet(com.facebook.presto.common.predicate.EquatableValueSet) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName) FullConnectorSession(com.facebook.presto.FullConnectorSession) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession) FullConnectorSession(com.facebook.presto.FullConnectorSession)

Example 3 with FullConnectorSession

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);
}
Also used : QualifiedTablePrefix(com.facebook.presto.metadata.QualifiedTablePrefix) FullConnectorSession(com.facebook.presto.FullConnectorSession) Session(com.facebook.presto.Session) ConnectorSession(com.facebook.presto.spi.ConnectorSession) FullConnectorSession(com.facebook.presto.FullConnectorSession)

Aggregations

FullConnectorSession (com.facebook.presto.FullConnectorSession)3 Session (com.facebook.presto.Session)3 QualifiedTablePrefix (com.facebook.presto.metadata.QualifiedTablePrefix)3 ConnectorSession (com.facebook.presto.spi.ConnectorSession)3 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)2 Domain (com.facebook.presto.common.predicate.Domain)2 EquatableValueSet (com.facebook.presto.common.predicate.EquatableValueSet)2 NullableValue (com.facebook.presto.common.predicate.NullableValue)2 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)2 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)2 VarcharType.createUnboundedVarcharType (com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType)2 Metadata (com.facebook.presto.metadata.Metadata)2 SchemaMetadataBuilder.schemaMetadataBuilder (com.facebook.presto.metadata.MetadataUtil.SchemaMetadataBuilder.schemaMetadataBuilder)2 TableMetadataBuilder.tableMetadataBuilder (com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder)2 MetadataUtil.findColumnMetadata (com.facebook.presto.metadata.MetadataUtil.findColumnMetadata)2 ColumnHandle (com.facebook.presto.spi.ColumnHandle)2 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)2 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)2 ConnectorTableLayout (com.facebook.presto.spi.ConnectorTableLayout)2 ConnectorTableLayoutHandle (com.facebook.presto.spi.ConnectorTableLayoutHandle)2