private static Integer checkNumDistributionKey(int cnd, int pnd) {
    // number of distribution keys of cRS is chosen only when numDistKeys of pRS
    // is 0 or less. In all other cases, distribution of the keys is based on
    // the pRS which is more generic than cRS.
    // Examples:
    // case 1: if pRS sort key is (a, b) and cRS sort key is (a, b, c) and number of
    // distribution keys are 2 and 3 resp. then after merge the sort keys will
    // be (a, b, c) while the number of distribution keys will be 2.
    // case 2: if pRS sort key is empty and number of distribution keys is 0
    // and if cRS sort key is (a, b) and number of distribution keys is 2 then
    // after merge new sort key will be (a, b) and number of distribution keys
    // will be 2.
    if (pnd <= 0) {
      return 1;
    }
    return 0;
  }
Checks if the partitioning columns of the child RS can replace the columns of the parent RS.

The replacement can be done in two cases:
<ul>
  <li>Parent RS columns are more specific than those of the child RS, and child columns are assigned;</li>
  <li>Child RS columns are more specific than those of the parent RS, and parent columns are not assigned.</li>
</ul>

@param moveColTo -1 if parent columns are more specific, 1 if child columns are more specific, 0 if the columns are
equal
@param cpars the child RS partitioning columns
@param ppars the parent RS partitioning columns
@return
 true if the partitioning columns of the child RS can replace the columns of the parent RS and false otherwise
ql/src/java/org/apache/hadoop/hive/ql/optimizer/correlation/ReduceSinkDeDuplicationUtils.java