private void insertAnalyzePipeline(String command, boolean rewritten) throws SemanticException {
    // 1. Based on the statement, generate the selectOperator
    Operator<?> selOp = null;
    try {
      selOp = genSelOp(command, rewritten, origCtx);
    } catch (ParseException e) {
      throw new SemanticException(e);
    }

    // 2. attach this SEL to the operator right before FS
    op.getChildOperators().add(selOp);
    selOp.getParentOperators().clear();
    selOp.getParentOperators().add(op);

    // 3. address the colExp, colList, etc for the SEL
    try {
      replaceSelectOperatorProcess((SelectOperator)selOp, op);
    } catch (HiveException e) {
      throw new SemanticException(e);
    }
  }
Generate the statement of SELECT compute_stats(col1) compute_stats(col2),...,
similar to the one generated from ANALYZE TABLE t1 COMPUTE STATISTICS FOR COLUMNS,
but t1 is replaced by a TABLE(VALUES(cast(null as int),cast(null as string))) AS t1(col1,col2).

We use TABLE-VALUES statement for computing stats for CTAS statement because in those cases
the table has not been created yet. Once the plan for the SELECT statement is generated,
we connect it to the existing CTAS plan as we do for INSERT or INSERT OVERWRITE.
ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsAutoGatherContext.java