Search in sources :

Example 6 with QualifiedTablePrefix

use of io.prestosql.metadata.QualifiedTablePrefix in project hetu-core by openlookeng.

the class InformationSchemaPageSourceProvider method buildTables.

private InternalTable buildTables(Session session, Set<QualifiedTablePrefix> prefixes) {
    InternalTable.Builder table = InternalTable.builder(informationSchemaTableColumns(TABLE_TABLES));
    for (QualifiedTablePrefix prefix : prefixes) {
        Set<SchemaTableName> tables = listTables(session, metadata, accessControl, prefix);
        Set<SchemaTableName> views = listViews(session, metadata, accessControl, prefix);
        for (SchemaTableName name : union(tables, views)) {
            // if table and view names overlap, the view wins
            String type = views.contains(name) ? "VIEW" : "BASE TABLE";
            table.add(prefix.getCatalogName(), name.getSchemaName(), name.getTableName(), type, null);
        }
    }
    return table.build();
}
Also used : QualifiedTablePrefix(io.prestosql.metadata.QualifiedTablePrefix) InternalTable(io.prestosql.metadata.InternalTable) SchemaTableName(io.prestosql.spi.connector.SchemaTableName)

Example 7 with QualifiedTablePrefix

use of io.prestosql.metadata.QualifiedTablePrefix in project hetu-core by openlookeng.

the class ColumnJdbcTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
    Session session = toSession(transactionHandle, connectorSession);
    Optional<String> catalogFilter = stringFilter(constraint, 0);
    Optional<String> schemaFilter = stringFilter(constraint, 1);
    Optional<String> tableFilter = stringFilter(constraint, 2);
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
        QualifiedTablePrefix prefix = FilterUtil.tablePrefix(catalog, schemaFilter, tableFilter);
        for (Entry<SchemaTableName, List<ColumnMetadata>> entry : listTableColumns(session, metadata, accessControl, prefix).entrySet()) {
            addColumnRows(table, catalog, entry.getKey(), entry.getValue());
        }
    }
    return table.build().cursor();
}
Also used : QualifiedTablePrefix(io.prestosql.metadata.QualifiedTablePrefix) Builder(io.prestosql.spi.connector.InMemoryRecordSet.Builder) TableMetadataBuilder.tableMetadataBuilder(io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) List(java.util.List) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) Session(io.prestosql.Session) SystemConnectorSessionUtil.toSession(io.prestosql.connector.system.SystemConnectorSessionUtil.toSession)

Example 8 with QualifiedTablePrefix

use of io.prestosql.metadata.QualifiedTablePrefix in project hetu-core by openlookeng.

the class TableJdbcTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
    Session session = toSession(transactionHandle, connectorSession);
    Optional<String> catalogFilter = stringFilter(constraint, 0);
    Optional<String> schemaFilter = stringFilter(constraint, 1);
    Optional<String> tableFilter = stringFilter(constraint, 2);
    Optional<String> typeFilter = stringFilter(constraint, 3);
    Builder table = InMemoryRecordSet.builder(METADATA);
    for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
        QualifiedTablePrefix prefix = tablePrefix(catalog, schemaFilter, tableFilter);
        if (FilterUtil.emptyOrEquals(typeFilter, "TABLE")) {
            for (SchemaTableName name : listTables(session, metadata, accessControl, prefix)) {
                table.addRow(tableRow(catalog, name, "TABLE"));
            }
        }
        if (FilterUtil.emptyOrEquals(typeFilter, "VIEW")) {
            for (SchemaTableName name : listViews(session, metadata, accessControl, prefix)) {
                table.addRow(tableRow(catalog, name, "VIEW"));
            }
        }
    }
    return table.build().cursor();
}
Also used : QualifiedTablePrefix(io.prestosql.metadata.QualifiedTablePrefix) Builder(io.prestosql.spi.connector.InMemoryRecordSet.Builder) TableMetadataBuilder.tableMetadataBuilder(io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) SystemConnectorSessionUtil.toSession(io.prestosql.connector.system.SystemConnectorSessionUtil.toSession) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) Session(io.prestosql.Session)

Aggregations

QualifiedTablePrefix (io.prestosql.metadata.QualifiedTablePrefix)8 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)7 Session (io.prestosql.Session)6 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)6 TableMetadataBuilder.tableMetadataBuilder (io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder)5 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 FullConnectorSession (io.prestosql.FullConnectorSession)3 SystemConnectorSessionUtil.toSession (io.prestosql.connector.system.SystemConnectorSessionUtil.toSession)3 Metadata (io.prestosql.metadata.Metadata)3 ColumnMetadata (io.prestosql.spi.connector.ColumnMetadata)3 ConnectorTableMetadata (io.prestosql.spi.connector.ConnectorTableMetadata)3 QualifiedObjectName (io.prestosql.spi.connector.QualifiedObjectName)3 TupleDomain (io.prestosql.spi.predicate.TupleDomain)3 VarcharType.createUnboundedVarcharType (io.prestosql.spi.type.VarcharType.createUnboundedVarcharType)3 List (java.util.List)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 Predicates.compose (com.google.common.base.Predicates.compose)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2