use of com.facebook.presto.hive.metastore.PrestoTableType.VIRTUAL_VIEW in project presto by prestodb.
the class HiveMetadata method getPropertiesSystemTable.
private Optional<SystemTable> getPropertiesSystemTable(ConnectorSession session, SchemaTableName tableName, SchemaTableName sourceTableName) {
MetastoreContext metastoreContext = getMetastoreContext(session);
Optional<Table> table = metastore.getTable(metastoreContext, sourceTableName.getSchemaName(), sourceTableName.getTableName());
if (!table.isPresent() || table.get().getTableType().equals(VIRTUAL_VIEW)) {
throw new TableNotFoundException(tableName);
}
Map<String, String> sortedTableParameters = ImmutableSortedMap.copyOf(table.get().getParameters());
List<ColumnMetadata> columns = sortedTableParameters.keySet().stream().map(key -> new ColumnMetadata(key, VARCHAR)).collect(toImmutableList());
List<Type> types = columns.stream().map(ColumnMetadata::getType).collect(toImmutableList());
Iterable<List<Object>> propertyValues = ImmutableList.of(ImmutableList.copyOf(sortedTableParameters.values()));
return Optional.of(createSystemTable(new ConnectorTableMetadata(sourceTableName, columns), constraint -> new InMemoryRecordSet(types, propertyValues).cursor()));
}
Aggregations