@Override
  public int execute() throws HiveException {
    String tableName = desc.getTableName();
    Map<String, String> oldPartSpec = desc.getOldPartSpec();
    ReplicationSpec replicationSpec = desc.getReplicationSpec();

    if (!AlterTableUtils.allowOperationInReplicationScope(context.getDb(), tableName, oldPartSpec, replicationSpec)) {
      // no rename, the table is missing either due to drop/rename which follows the current rename.
      // or the existing table is newer than our update.
      LOG.debug("DDLTask: Rename Partition is skipped as table {} / partition {} is newer than update", tableName,
              FileUtils.makePartName(new ArrayList<>(oldPartSpec.keySet()), new ArrayList<>(oldPartSpec.values())));
      return 0;
    }

    if (Utils.isBootstrapDumpInProgress(context.getDb(), HiveTableName.of(tableName).getDb())) {
      LOG.error("DDLTask: Rename Partition not allowed as bootstrap dump in progress");
      throw new HiveException("Rename Partition: Not allowed as bootstrap dump in progress");
    }

    Table tbl = context.getDb().getTable(tableName);
    Partition oldPart = context.getDb().getPartition(tbl, oldPartSpec, false);
    if (oldPart == null) {
      String partName = FileUtils.makePartName(new ArrayList<String>(oldPartSpec.keySet()),
          new ArrayList<String>(oldPartSpec.values()));
      throw new HiveException("Rename partition: source partition [" + partName + "] does not exist.");
    }

    Partition part = context.getDb().getPartition(tbl, oldPartSpec, false);
    part.setValues(desc.getNewPartSpec());

    long writeId = desc.getWriteId();

    context.getDb().renamePartition(tbl, oldPartSpec, part, writeId);
    Partition newPart = context.getDb().getPartition(tbl, desc.getNewPartSpec(), false);
    context.getWork().getInputs().add(new ReadEntity(oldPart));

    // We've already obtained a lock on the table, don't lock the partition too
    DDLUtils.addIfAbsentByName(new WriteEntity(newPart, WriteEntity.WriteType.DDL_NO_LOCK), context);

    return 0;
  }
Operation process of renaming a partition of a table.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/rename/AlterTableRenamePartitionOperation.java