private void buildAddClauseForAlter(StringBuilder query) {
    if (validWriteIdList == null || dir == null) {
      query.setLength(0);
      return;  // avoid NPEs, don't throw an exception but return an empty query
    }
    long minWriteID = validWriteIdList.getMinOpenWriteId() == null ? 1 : validWriteIdList.getMinOpenWriteId();
    long highWatermark = validWriteIdList.getHighWatermark();
    List<AcidUtils.ParsedDelta> deltas = dir.getCurrentDirectories().stream().filter(
            delta -> delta.isDeleteDelta() == isDeleteDelta && delta.getMaxWriteId() <= highWatermark && delta.getMinWriteId() >= minWriteID)
        .collect(Collectors.toList());
    if (deltas.isEmpty()) {
      query.setLength(0); // no alter query needed; clear StringBuilder
      return;
    }
    query.append(" add ");
    deltas.forEach(
        delta -> query.append("partition (file_name='").append(delta.getPath().getName()).append("') location '")
            .append(delta.getPath()).append("' "));
  }
Part of Create operation. All tmp tables are not transactional and are marked as
compaction tables. Additionally...
- Crud compaction temp tables need tblproperty, "compactiontable."
- Minor crud compaction temp tables need bucketing version tblproperty, if table is bucketed.
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactionQueryBuilder.java