private String buildAlterTableQuery(String tableName, AcidDirectory dir,
      ValidWriteIdList validWriteIdList) {
    return new CompactionQueryBuilderFactory().getCompactionQueryBuilder(
        CompactionType.MINOR, true)
        .setOperation(CompactionQueryBuilder.Operation.ALTER)
        .setResultTableName(tableName)
        .setDir(dir)
        .setValidWriteIdList(validWriteIdList)
        .build();
  }
Builds an alter table query, which adds partitions pointing to location of delta directories.

@param tableName name of the temp table to be altered
@param dir the parent directory of delta directories
@param validWriteIdList valid write ids for the table/partition to compact
@return alter table statement.
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/MmMinorQueryCompactor.java