public void patchProjectionForUpdate(ASTNode insertBranch, Map<Integer, ASTNode> setColExprs) {
    ASTNode rewrittenSelect = (ASTNode) insertBranch.getChildren().get(1);
    assert rewrittenSelect.getToken().getType() == HiveParser.TOK_SELECT :
        "Expected TOK_SELECT as second child of TOK_INSERT but found " + rewrittenSelect.getName();
    for (Map.Entry<Integer, ASTNode> entry : setColExprs.entrySet()) {
      ASTNode selExpr = (ASTNode) rewrittenSelect.getChildren().get(entry.getKey());
      assert selExpr.getToken().getType() == HiveParser.TOK_SELEXPR :
          "Expected child of TOK_SELECT to be TOK_SELEXPR but was " + selExpr.getName();
      // Now, change it's child
      selExpr.setChild(0, entry.getValue());
    }
  }
Patch up the projection list for updates, putting back the original set expressions.
Walk through the projection list and replace the column names with the
expressions from the original update.  Under the TOK_SELECT (see above) the structure
looks like:
<pre>
TOK_SELECT -&gt; TOK_SELEXPR -&gt; expr
          \-&gt; TOK_SELEXPR -&gt; expr ...
</pre>
ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/sql/SetClausePatcher.java