private MPartition convertToMPart(Partition part, MTable mt)
      throws InvalidObjectException, MetaException {
    // NOTE: we don't set writeId in this method. Write ID is only set after validating the
    //       existing write ID against the caller's valid list.
    if (part == null) {
      return null;
    }
    if (mt == null) {
      throw new InvalidObjectException(
          "Partition doesn't have a valid table or database name");
    }

    // If this partition's set of columns is the same as the parent table's,
    // use the parent table's, so we do not create a duplicate column descriptor,
    // thereby saving space
    MStorageDescriptor msd;
    if (mt.getSd() != null && mt.getSd().getCD() != null &&
        mt.getSd().getCD().getCols() != null &&
        part.getSd() != null &&
        convertToFieldSchemas(mt.getSd().getCD().getCols()).
        equals(part.getSd().getCols())) {
      msd = convertToMStorageDescriptor(part.getSd(), mt.getSd().getCD());
    } else {
      msd = convertToMStorageDescriptor(part.getSd());
    }

    return new MPartition(Warehouse.makePartName(convertToFieldSchemas(mt
        .getPartitionKeys()), part.getValues()), mt, part.getValues(), part
        .getCreateTime(), part.getLastAccessTime(),
        msd, part.getParameters());
  }
Convert a Partition object into an MPartition, which is an object backed by the db
If the Partition's set of columns is the same as the parent table's AND useTableCD
is true, then this partition's storage descriptor's column descriptor will point
to the same one as the table's storage descriptor.
@param part the partition to convert
@param mt the parent table object
@return the model partition object, and null if the input partition is null.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java