private void gatherCTEReferences(QB qb, CTEClause current,
                                   Map<String, CTEClause> materializationAliasToCTEs) throws HiveException {
    for (String alias : qb.getTabAliases()) {
      String tabName = qb.getTabNameForAlias(alias);
      String cteName = tabName.toLowerCase();

      CTEClause cte = findCTEFromName(qb, cteName, materializationAliasToCTEs);
      if (cte != null) {
        cte.reference++;
        current.parents.add(cte);
        if (cte.qbExpr != null) {
          continue;
        }
        cte.qbExpr = new QBExpr(cteName);
        doPhase1QBExpr(cte.cteNode, cte.qbExpr, qb.getId(), cteName, cte.withColList, materializationAliasToCTEs);
        gatherCTEReferences(cte.qbExpr, cte, materializationAliasToCTEs);
      }
    }
    for (String alias : qb.getSubqAliases()) {
      gatherCTEReferences(qb.getSubqForAlias(alias), current, materializationAliasToCTEs);
    }
    for (String alias : qb.getSubqExprAliases()) {
      gatherCTEReferences(qb.getSubqExprForAlias(alias), current, materializationAliasToCTEs);
    }
  }
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