use of io.trino.plugin.thrift.api.TrinoThriftSchemaTableName in project trino by trinodb.
the class ThriftTpchService method getTableMetadata.
@Override
public final TrinoThriftNullableTableMetadata getTableMetadata(TrinoThriftSchemaTableName schemaTableName) {
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
if (!SCHEMAS.contains(schemaName) || TpchTable.getTables().stream().noneMatch(table -> table.getTableName().equals(tableName))) {
return new TrinoThriftNullableTableMetadata(null);
}
TpchTable<?> tpchTable = TpchTable.getTable(schemaTableName.getTableName());
List<TrinoThriftColumnMetadata> columns = new ArrayList<>();
for (TpchColumn<? extends TpchEntity> column : tpchTable.getColumns()) {
columns.add(new TrinoThriftColumnMetadata(column.getSimplifiedColumnName(), getTypeString(column), null, false));
}
List<Set<String>> indexableKeys = getIndexableKeys(schemaName, tableName);
return new TrinoThriftNullableTableMetadata(new TrinoThriftTableMetadata(schemaTableName, columns, null, !indexableKeys.isEmpty() ? indexableKeys : null));
}
Aggregations