private static boolean createChildColumnRef(Tree child, String alias,
      List<ASTNode> newChildren, Set<String> aliases, Context ctx) {
    String colAlias = child.getText();
    if (SemanticAnalyzer.isRegex(colAlias, (HiveConf)ctx.getConf())) {
      LOG.debug("Skip creating child column reference because of regexp used as alias: " + colAlias);
      return false;
    }
    if (!aliases.add(colAlias)) {
      // TODO: if a side of the union has 2 columns with the same name, none on the higher
      //       level can refer to them. We could change the alias in the original node.
      LOG.debug("Replacing SETCOLREF with ALLCOLREF because of duplicate alias " + colAlias);
      return false;
    }
    ASTBuilder selExpr = ASTBuilder.construct(HiveParser.TOK_SELEXPR, "TOK_SELEXPR");
    ASTBuilder toc = ASTBuilder.construct(HiveParser.TOK_TABLE_OR_COL, "TOK_TABLE_OR_COL");
    ASTBuilder id = ASTBuilder.construct(HiveParser.Identifier, colAlias);
    if (alias == null) {
      selExpr = selExpr.add(toc.add(id));
    } else {
      ASTBuilder dot = ASTBuilder.construct(HiveParser.DOT, ".");
      ASTBuilder aliasNode = ASTBuilder.construct(HiveParser.Identifier, alias);
      selExpr = selExpr.add(dot.add(toc.add(aliasNode)).add(id));
    }
    newChildren.add(selExpr.node());
    return true;
  }
Replaces a spurious TOK_SETCOLREF added by parser with column names referring to the query
in e.g. a union. This is to maintain the expectations that some code, like order by position
alias, might have about not having ALLCOLREF. If it cannot find the columns with confidence
it will just replace SETCOLREF with ALLCOLREF. Most of the cases where that happens are
easy to work around in the query (e.g. by adding column aliases in the union).
@param setCols TOK_SETCOLREF ASTNode.
@param searcher AST searcher to reuse.
ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java