use of io.trino.spi.connector.ConnectorTableMetadata in project trino by trinodb.
the class InformationSchemaMetadata method getColumnMetadata.
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) {
InformationSchemaTableHandle informationSchemaTableHandle = (InformationSchemaTableHandle) tableHandle;
ConnectorTableMetadata tableMetadata = informationSchemaTableHandle.getTable().getTableMetadata();
String columnName = ((InformationSchemaColumnHandle) columnHandle).getColumnName();
ColumnMetadata columnMetadata = findColumnMetadata(tableMetadata, columnName);
checkArgument(columnMetadata != null, "Column '%s' on table '%s' does not exist", columnName, tableMetadata.getTable());
return columnMetadata;
}
use of io.trino.spi.connector.ConnectorTableMetadata in project trino by trinodb.
the class InformationSchemaMetadata method getColumnHandles.
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) {
InformationSchemaTableHandle informationSchemaTableHandle = (InformationSchemaTableHandle) tableHandle;
ConnectorTableMetadata tableMetadata = informationSchemaTableHandle.getTable().getTableMetadata();
return tableMetadata.getColumns().stream().map(ColumnMetadata::getName).collect(toImmutableMap(identity(), InformationSchemaColumnHandle::new));
}
use of io.trino.spi.connector.ConnectorTableMetadata in project trino by trinodb.
the class SystemTablesMetadata method listTableColumns.
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
if (prefix.getTable().isPresent()) {
// 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.buildOrThrow();
}
use of io.trino.spi.connector.ConnectorTableMetadata in project trino by trinodb.
the class SystemTablesMetadata method getColumnMetadata.
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) {
ConnectorTableMetadata tableMetadata = checkAndGetTable(session, tableHandle).getTableMetadata();
String columnName = ((SystemColumnHandle) columnHandle).getColumnName();
ColumnMetadata columnMetadata = findColumnMetadata(tableMetadata, columnName);
checkArgument(columnMetadata != null, "Column '%s' on table '%s' does not exist", columnName, tableMetadata.getTable());
return columnMetadata;
}
use of io.trino.spi.connector.ConnectorTableMetadata in project trino by trinodb.
the class ExampleMetadata method listTableColumns.
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
for (SchemaTableName tableName : listTables(session, prefix)) {
ConnectorTableMetadata tableMetadata = getTableMetadata(tableName);
// table can disappear during listing operation
if (tableMetadata != null) {
columns.put(tableName, tableMetadata.getColumns());
}
}
return columns.buildOrThrow();
}
Aggregations