use of org.apache.calcite.rel.RelFieldCollation.Direction in project hive by apache.
the class RelOptHiveTable method getCollationList.
@Override
public List<RelCollation> getCollationList() {
ImmutableList.Builder<RelFieldCollation> collationList = new ImmutableList.Builder<RelFieldCollation>();
for (Order sortColumn : this.hiveTblMetadata.getSortCols()) {
for (int i = 0; i < this.hiveTblMetadata.getSd().getCols().size(); i++) {
FieldSchema field = this.hiveTblMetadata.getSd().getCols().get(i);
if (field.getName().equals(sortColumn.getCol())) {
Direction direction;
NullDirection nullDirection;
if (sortColumn.getOrder() == BaseSemanticAnalyzer.HIVE_COLUMN_ORDER_ASC) {
direction = Direction.ASCENDING;
nullDirection = NullDirection.FIRST;
} else {
direction = Direction.DESCENDING;
nullDirection = NullDirection.LAST;
}
collationList.add(new RelFieldCollation(i, direction, nullDirection));
break;
}
}
}
return new ImmutableList.Builder<RelCollation>().add(RelCollationTraitDef.INSTANCE.canonize(new HiveRelCollation(collationList.build()))).build();
}
Aggregations