public static Set<ImmutableBitSet> getUniqueKeys(RelNode rel) {
    rel = getRelNode(rel);
    if (rel instanceof HiveFilter) {
      return getUniqueKeys((HiveFilter) rel);
    } else if (rel instanceof HiveSortLimit) {
      return getUniqueKeys((HiveSortLimit) rel);
    } else if (rel instanceof Correlate) {
      return getUniqueKeys((Correlate) rel);
    } else if (rel instanceof HiveProject) {
      return getUniqueKeys((HiveProject) rel);
    } else if (rel instanceof HiveJoin) {
      return getUniqueKeys((HiveJoin) rel);
    } else if (rel instanceof HiveSemiJoin) {
      return getUniqueKeys((HiveSemiJoin) rel);
    } else if (rel instanceof HiveAntiJoin) {
      return getUniqueKeys((HiveAntiJoin) rel);
    } else if (rel instanceof HiveAggregate) {
      return getUniqueKeys((HiveAggregate) rel);
    } else if (rel instanceof SetOp) {
      return getUniqueKeys((SetOp) rel);
    } else {
      return null;
    }
  }
EstimateUniqueKeys provides an ability to estimate unique keys based on statistics.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/EstimateUniqueKeys.java