Search in sources :

Example 1 with MongodbIndexKey

use of io.trino.plugin.mongodb.MongoIndex.MongodbIndexKey in project trino by trinodb.

the class MongoMetadata method getTableProperties.

@Override
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) {
    MongoTableHandle tableHandle = (MongoTableHandle) table;
    // TODO: sharding key
    Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty();
    ImmutableList.Builder<LocalProperty<ColumnHandle>> localProperties = ImmutableList.builder();
    MongoTable tableInfo = mongoSession.getTable(tableHandle.getSchemaTableName());
    Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);
    for (MongoIndex index : tableInfo.getIndexes()) {
        for (MongodbIndexKey key : index.getKeys()) {
            if (key.getSortOrder().isEmpty()) {
                continue;
            }
            if (columns.get(key.getName()) != null) {
                localProperties.add(new SortingProperty<>(columns.get(key.getName()), key.getSortOrder().get()));
            }
        }
    }
    return new ConnectorTableProperties(TupleDomain.all(), Optional.empty(), partitioningColumns, Optional.empty(), localProperties.build());
}
Also used : ColumnHandle(io.trino.spi.connector.ColumnHandle) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) MongodbIndexKey(io.trino.plugin.mongodb.MongoIndex.MongodbIndexKey) LocalProperty(io.trino.spi.connector.LocalProperty) ConnectorTableProperties(io.trino.spi.connector.ConnectorTableProperties)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 MongodbIndexKey (io.trino.plugin.mongodb.MongoIndex.MongodbIndexKey)1 ColumnHandle (io.trino.spi.connector.ColumnHandle)1 ConnectorTableProperties (io.trino.spi.connector.ConnectorTableProperties)1 LocalProperty (io.trino.spi.connector.LocalProperty)1 Set (java.util.Set)1