protected void buildWhereClauseForInsert(StringBuilder query) {
    if (sourcePartition != null && sourceTab != null) {
      List<String> vals = sourcePartition.getValues();
      List<FieldSchema> keys = sourceTab.getPartitionKeys();
      if (keys.size() != vals.size()) {
        throw new IllegalStateException("source partition values (" + Arrays.toString(
            vals.toArray()) + ") do not match source table values (" + Arrays.toString(
            keys.toArray()) + "). Failing compaction.");
      }

      query.append(" where ");
      for (int i = 0; i < keys.size(); ++i) {
        FieldSchema keySchema = keys.get(i);
        query.append(i == 0 ? "`" : " and `").append(keySchema.getName()).append("`=");
        if (!keySchema.getType().equalsIgnoreCase(ColumnType.BOOLEAN_TYPE_NAME)) {
          query.append("'").append(vals.get(i)).append("'");
        } else {
          query.append(vals.get(i));
        }
      }
    }
  }
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