use of com.facebook.presto.spi.SchemaTablePrefix in project presto by prestodb.
the class SystemTablesMetadata method listTableColumns.
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
if (prefix.getTableName() != null) {
// if table is concrete we just use tables.getSystemTable to support tables which are not listable
SchemaTableName tableName = prefix.toSchemaTableName();
return tables.getSystemTable(session, tableName).map(systemTable -> singletonMap(tableName, systemTable.getTableMetadata().getColumns())).orElseGet(ImmutableMap::of);
}
ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> builder = ImmutableMap.builder();
for (SystemTable table : tables.listSystemTables(session)) {
ConnectorTableMetadata tableMetadata = table.getTableMetadata();
if (prefix.matches(tableMetadata.getTable())) {
builder.put(tableMetadata.getTable(), tableMetadata.getColumns());
}
}
return builder.build();
}
use of com.facebook.presto.spi.SchemaTablePrefix in project presto by prestodb.
the class AbstractTestHiveClient method testListUnknownSchema.
@Test
public void testListUnknownSchema() {
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
ConnectorSession session = newSession();
assertNull(metadata.getTableHandle(session, new SchemaTableName(INVALID_DATABASE, INVALID_TABLE)));
assertEquals(metadata.listTables(session, INVALID_DATABASE), ImmutableList.of());
assertEquals(metadata.listTableColumns(session, new SchemaTablePrefix(INVALID_DATABASE, INVALID_TABLE)), ImmutableMap.of());
assertEquals(metadata.listViews(session, INVALID_DATABASE), ImmutableList.of());
assertEquals(metadata.getViews(session, new SchemaTablePrefix(INVALID_DATABASE, INVALID_TABLE)), ImmutableMap.of());
}
}
use of com.facebook.presto.spi.SchemaTablePrefix in project presto by prestodb.
the class AbstractTestHiveClient method testHiveViewsHaveNoColumns.
@Test
public void testHiveViewsHaveNoColumns() {
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
assertEquals(metadata.listTableColumns(newSession(), new SchemaTablePrefix(view.getSchemaName(), view.getTableName())), ImmutableMap.of());
}
}
use of com.facebook.presto.spi.SchemaTablePrefix in project presto by prestodb.
the class TestRaptorMetadata method testListTableColumnsFiltering.
@Test
public void testListTableColumnsFiltering() {
metadata.createTable(SESSION, getOrdersTable(), false);
Map<SchemaTableName, List<ColumnMetadata>> filterCatalog = metadata.listTableColumns(SESSION, new SchemaTablePrefix());
Map<SchemaTableName, List<ColumnMetadata>> filterSchema = metadata.listTableColumns(SESSION, new SchemaTablePrefix("test"));
Map<SchemaTableName, List<ColumnMetadata>> filterTable = metadata.listTableColumns(SESSION, new SchemaTablePrefix("test", "orders"));
assertEquals(filterCatalog, filterSchema);
assertEquals(filterCatalog, filterTable);
}
Aggregations