use of com.datastax.oss.driver.api.core.metadata.schema.RelationMetadata in project calcite by apache.
the class CassandraSchema method getClusteringOrder.
/**
* Get the collation of all clustering key columns.
*
* @return A RelCollations representing the collation of all clustering keys
*/
public List<RelFieldCollation> getClusteringOrder(String columnFamily, boolean isView) {
RelationMetadata table = getRelationMetadata(columnFamily, isView);
Collection<ClusteringOrder> clusteringOrder = table.getClusteringColumns().values();
List<RelFieldCollation> keyCollations = new ArrayList<>();
int i = 0;
for (ClusteringOrder order : clusteringOrder) {
RelFieldCollation.Direction direction;
switch(order) {
case DESC:
direction = RelFieldCollation.Direction.DESCENDING;
break;
case ASC:
default:
direction = RelFieldCollation.Direction.ASCENDING;
break;
}
keyCollations.add(new RelFieldCollation(i, direction));
i++;
}
return keyCollations;
}
Aggregations