@Override
  protected void buildSelectClauseForInsert(StringBuilder query) {
    // Need list of columns fir major crud compaction.
    // If the source table is null, don't throw an exception, but skip this part of the query
    if (sourceTab != null) {
      List<FieldSchema> cols = sourceTab.getSd().getCols();

      query.append(
          "validate_acid_sort_order(ROW__ID.writeId, ROW__ID.bucketId, ROW__ID.rowId), ROW__ID.writeId, ROW__ID.bucketId, ROW__ID.rowId, ROW__ID.writeId, NAMED_STRUCT(");
      appendColumns(query, cols, true);
      query.append(") ");
    }
  }
Builds query strings that help with query-based MAJOR compaction of CRUD.
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactionQueryBuilderForMajor.java