private static Integer checkExprs(List<ExprNodeDesc> ckeys, List<ExprNodeDesc> pkeys,
      ReduceSinkOperator cRS, ReduceSinkOperator pRS) throws SemanticException {
    // If ckeys or pkeys have constant node expressions avoid the merge.
    for (ExprNodeDesc ck : ckeys) {
      if (ck instanceof ExprNodeConstantDesc) {
        return null;
      }
    }
    for (ExprNodeDesc pk : pkeys) {
      if (pk instanceof ExprNodeConstantDesc) {
        return null;
      }
    }

    Integer moveKeyColTo = 0;
    if (ckeys == null || ckeys.isEmpty()) {
      if (pkeys != null && !pkeys.isEmpty()) {
        moveKeyColTo = -1;
      }
    } else {
      if (pkeys == null || pkeys.isEmpty()) {
        for (ExprNodeDesc ckey : ckeys) {
          if (ExprNodeDescUtils.backtrack(ckey, cRS, pRS) == null) {
            // cKey is not present in parent
            return null;
          }
        }
        moveKeyColTo = 1;
      } else {
        moveKeyColTo = sameKeys(ckeys, pkeys, cRS, pRS);
      }
    }
    return moveKeyColTo;
  }
Overlapping part of keys should be the same between parent and child.
And if child has more keys than parent, non-overlapping part of keys
should be backtrackable to parent.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/correlation/ReduceSinkDeDuplicationUtils.java