private int getColumnIndex(Table tbl) throws HiveException {
    int colIndex = -1;
    for (FieldSchema col : tbl.getTTable().getPartitionKeys()) {
      colIndex++;
      if (col.getName().compareTo(desc.getPartKeyName()) == 0) {
        return colIndex;
      }
    }

    throw new HiveException("Cannot find partition column " + desc.getPartKeyName());
  }
Operation process of altering a partition to a table.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/alter/AlterTableAlterPartitionOperation.java