@Override
  protected void analyzeCommand(TableName tableName, Map<String, String> partitionSpecFromFramework, ASTNode command)
      throws SemanticException {
    Table table = getTable(tableName);
    validateAlterTableType(table, AlterTableType.TOUCH, false);
    inputs.add(new ReadEntity(table));

    List<Map<String, String>> partitionSpecs = getPartitionSpecs(table, command);

    if (partitionSpecs.isEmpty()) {
      AlterTableTouchDesc desc = new AlterTableTouchDesc(tableName.getNotEmptyDbTable(), null);
      outputs.add(new WriteEntity(table, WriteEntity.WriteType.DDL_NO_LOCK));
      rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
    } else {
      PartitionUtils.addTablePartsOutputs(db, outputs, table, partitionSpecs, false, WriteEntity.WriteType.DDL_NO_LOCK);
      for (Map<String, String> partitionSpec : partitionSpecs) {
        AlterTableTouchDesc desc = new AlterTableTouchDesc(tableName.getNotEmptyDbTable(), partitionSpec);
        rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
      }
    }
  }
Analyzer for touch commands.

Rewrite the metadata for one or more partitions in a table. Useful when an external process modifies files on HDFS
and you want the pre/post hooks to be fired for the specified partition.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/misc/touch/AlterTableTouchAnalyzer.java