@Override
    public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx ctx, Object... nodeOutputs)
        throws SemanticException {
      SelectOperator op = (SelectOperator) nd;
      ConstantPropagateProcCtx cppCtx = (ConstantPropagateProcCtx) ctx;
      Map<ColumnInfo, ExprNodeDesc> constants = cppCtx.getPropagatedConstants(op);
      cppCtx.getOpToConstantExprs().put(op, constants);
      foldOperator(op, cppCtx);
      List<ExprNodeDesc> colList = op.getConf().getColList();
      List<String> columnNames = op.getConf().getOutputColumnNames();
      Map<String, ExprNodeDesc> columnExprMap = op.getColumnExprMap();
      if (colList != null) {
        for (int i = 0; i < colList.size(); i++) {
          ExprNodeDesc newCol = foldExpr(colList.get(i), constants, cppCtx, op, 0, false);
          if (!(colList.get(i) instanceof ExprNodeConstantDesc) && newCol instanceof ExprNodeConstantDesc) {
            // Lets try to store original column name, if this column got folded
            // This is useful for optimizations like GroupByOptimizer
            String colName = colList.get(i).getExprString();
            if (HiveConf.getPositionFromInternalName(colName) == -1) {
              // if its not an internal name, this is what we want.
              ((ExprNodeConstantDesc)newCol).setFoldedFromCol(colName);
              // See if we can set the tabAlias this was folded from as well.
              ExprNodeDesc colExpr = colList.get(i);
              if (colExpr instanceof ExprNodeColumnDesc) {
                ((ExprNodeConstantDesc)newCol).setFoldedFromTab(((ExprNodeColumnDesc) colExpr).getTabAlias());
              }
            } else {
              // If it was internal column, lets try to get name from columnExprMap
              ExprNodeDesc desc = columnExprMap.get(colName);
              if (desc instanceof ExprNodeConstantDesc) {
                ((ExprNodeConstantDesc)newCol).setFoldedFromCol(((ExprNodeConstantDesc)desc).getFoldedFromCol());
                ((ExprNodeConstantDesc)newCol).setFoldedFromTab(((ExprNodeConstantDesc)desc).getFoldedFromTab());
              }
            }
          }
          colList.set(i, newCol);
          if (op.getSchema() != null) {
            ColumnInfo colInfo = op.getSchema().getSignature().get(i);
            colInfo.setInternalName(columnNames.get(i));
            if (newCol instanceof ExprNodeConstantDesc ) {
              if (!VirtualColumn.isVirtualColumnBasedOnAlias(colInfo)) {
                constants.put(colInfo, newCol);
              }
            }
          }
          if (columnExprMap != null) {
            columnExprMap.put(columnNames.get(i), newCol);
          }
        }
        if (LOG.isDebugEnabled()) {
          LOG.debug("New column list:(" + StringUtils.join(colList, " ") + ")");
        }
      }
      return null;
    }
The Node Processor for Constant Propagation for Select Operators.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java