@Override
  public List<Partition> alterPartitions(String catName, String dbName, String tblName,
                              List<List<String>> part_vals, List<Partition> newParts,
                              long writeId, String queryWriteIdList)
                                  throws InvalidObjectException, MetaException {
    List<Partition> results = new ArrayList<>(newParts.size());
    if (newParts.isEmpty()) {
      return results;
    }
    catName = normalizeIdentifier(catName);
    dbName = normalizeIdentifier(dbName);
    tblName = normalizeIdentifier(tblName);

    boolean success = false;
    try {
      openTransaction();

      MTable table = ensureGetMTable(catName, dbName, tblName);
      // Validate new parts: StorageDescriptor and SerDeInfo must be set in Partition.
      if (!TableType.VIRTUAL_VIEW.name().equals(table.getTableType())) {
        for (Partition newPart : newParts) {
          if (!newPart.isSetSd() || !newPart.getSd().isSetSerdeInfo()) {
            throw new InvalidObjectException("Partition does not set storageDescriptor or serdeInfo.");
          }
        }
      }
      if (writeId > 0) {
        newParts.forEach(newPart -> newPart.setWriteId(writeId));
      }

      List<FieldSchema> partCols = convertToFieldSchemas(table.getPartitionKeys());
      List<String> partNames = new ArrayList<>();
      for (List<String> partVal : part_vals) {
        partNames.add(Warehouse.makePartName(partCols, partVal));
      }

      for (Partition tmpPart : newParts) {
        if (!tmpPart.getDbName().equalsIgnoreCase(table.getDatabase().getName())) {
          throw new MetaException("Invalid DB name : " + tmpPart.getDbName());
        }

        if (!tmpPart.getTableName().equalsIgnoreCase(table.getTableName())) {
          throw new MetaException("Invalid table name : " + tmpPart.getDbName());
        }
      }

      results = new GetListHelper<Partition>(catName, dbName, tblName, true, true) {
        @Override
        protected List<Partition> getSqlResult(GetHelper<List<Partition>> ctx)
            throws MetaException {
          return directSql.alterPartitions(table, partNames, newParts, queryWriteIdList);
        }

        @Override
        protected List<Partition> getJdoResult(GetHelper<List<Partition>> ctx)
            throws MetaException, InvalidObjectException {
          return alterPartitionsViaJdo(table, partNames, newParts, queryWriteIdList);
        }
      }.run(false);

      // commit the changes
      success = commitTransaction();
    } catch (Exception exception) {
      LOG.error("Alter failed", exception);
      throw new MetaException(exception.getMessage());
    } finally {
      rollbackAndCleanup(success, null);
    }
    return results;
  }
Alters an existing partition. Initiates copy of SD. Returns the old CD.
@param part_vals Partition values (of the original partition instance)
@param newPart Partition object containing new information
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java