use of com.facebook.presto.metadata.QualifiedTablePrefix in project presto by prestodb.
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 com.facebook.presto.metadata.QualifiedTablePrefix in project presto by prestodb.
the class InformationSchemaPageSourceProvider method buildTables.
private InternalTable buildTables(Session session, String catalogName, Map<String, NullableValue> filters) {
QualifiedTablePrefix prefix = extractQualifiedTablePrefix(catalogName, filters);
Set<SchemaTableName> tables = listTables(session, metadata, accessControl, prefix);
Set<SchemaTableName> views = listViews(session, metadata, accessControl, prefix);
InternalTable.Builder table = InternalTable.builder(informationSchemaTableColumns(TABLE_TABLES));
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(catalogName, name.getSchemaName(), name.getTableName(), type);
}
return table.build();
}
use of com.facebook.presto.metadata.QualifiedTablePrefix in project presto by prestodb.
the class InformationSchemaPageSourceProvider method buildColumns.
private InternalTable buildColumns(Session session, String catalogName, Map<String, NullableValue> filters) {
InternalTable.Builder table = InternalTable.builder(informationSchemaTableColumns(TABLE_COLUMNS));
QualifiedTablePrefix prefix = extractQualifiedTablePrefix(catalogName, filters);
for (Entry<SchemaTableName, List<ColumnMetadata>> entry : listTableColumns(session, metadata, accessControl, prefix).entrySet()) {
SchemaTableName tableName = entry.getKey();
int ordinalPosition = 1;
for (ColumnMetadata column : entry.getValue()) {
if (column.isHidden()) {
continue;
}
table.add(catalogName, tableName.getSchemaName(), tableName.getTableName(), column.getName(), ordinalPosition, null, "YES", column.getType().getDisplayName(), column.getComment(), column.getExtraInfo());
ordinalPosition++;
}
}
return table.build();
}
use of com.facebook.presto.metadata.QualifiedTablePrefix in project presto by prestodb.
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