public boolean shouldValidateCardinalityViolation(HiveConf conf) {
    if (!conf.getBoolVar(HiveConf.ConfVars.MERGE_CARDINALITY_VIOLATION_CHECK)) {
      LOG.info("Merge statement cardinality violation check is disabled: {}",
          HiveConf.ConfVars.MERGE_CARDINALITY_VIOLATION_CHECK.varname);
      return false;
    }
    //if no update or delete in Merge, there is no need to do cardinality check
    boolean onlyHaveWhenNotMatchedClause = whenClauses.size() == 1 && whenClauses.get(0) instanceof InsertClause;
    return !onlyHaveWhenNotMatchedClause;
  }
Per SQL Spec ISO/IEC 9075-2:2011(E) Section 14.2 under "General Rules" Item 6/Subitem a/Subitem 2/Subitem B,
an error should be raised if &gt; 1 row of "source" matches the same row in "target".
This should not affect the runtime of the query as it's running in parallel with other
branches of the multi-insert.  It won't actually write any data to merge_tmp_table since the
cardinality_violation() UDF throws an error whenever it's called killing the query
@return true if another Insert clause was added
ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/MergeStatement.java