private static Set<ImmutableBitSet> getUniqueKeys(HiveSortLimit rel) {
    return getUniqueKeys(rel.getInput());
  }
EstimateUniqueKeys provides an ability to estimate unique keys based on statistics.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/EstimateUniqueKeys.java