use of io.trino.plugin.thrift.api.TrinoThriftNullableTableMetadata 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));
}
use of io.trino.plugin.thrift.api.TrinoThriftNullableTableMetadata in project trino by trinodb.
the class ThriftMetadata method getTableMetadataInternal.
// this method makes actual thrift request and should be called only by cache load method
private Optional<ThriftTableMetadata> getTableMetadataInternal(SchemaTableName schemaTableName) {
requireNonNull(schemaTableName, "schemaTableName is null");
TrinoThriftNullableTableMetadata thriftTableMetadata = getTableMetadata(schemaTableName);
if (thriftTableMetadata.getTableMetadata() == null) {
return Optional.empty();
}
ThriftTableMetadata tableMetadata = new ThriftTableMetadata(thriftTableMetadata.getTableMetadata(), typeManager);
if (!Objects.equals(schemaTableName, tableMetadata.getSchemaTableName())) {
throw new TrinoException(THRIFT_SERVICE_INVALID_RESPONSE, "Requested and actual table names are different");
}
return Optional.of(tableMetadata);
}
Aggregations