private void checkRecursiveCTE(CTEClause current, Set<String> path) throws SemanticException {

    for (CTEClause child : current.parents) {
      if (path.contains(child.alias)) {
        throw new SemanticException("Recursive cte " + child.alias +
            " detected (cycle: " + StringUtils.join(path, " -> ") +
            " -> " + child.alias + ").");
      }
      path.add(child.alias);
      checkRecursiveCTE(child, path);
      path.remove(child.alias);
    }
  }
This is phase1 of supporting specifying schema in insert statement
insert into foo(z,y) select a,b from bar;
@see #handleInsertStatementSpec(java.util.List, String, RowResolver, QB, ASTNode)
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java