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();
}
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();
}
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();
}
Aggregations