private List<Partition> getPartitions(Table tbl, Map<String, String> partSpec, DDLOperationContext context)
      throws HiveException {
    List<Partition> partitions = null;
    if (partSpec != null) {
      if (AlterTableUtils.isFullPartitionSpec(tbl, partSpec)) {
        partitions = new ArrayList<Partition>();
        Partition part = context.getDb().getPartition(tbl, partSpec, false);
        if (part == null) {
          // User provided a fully specified partition spec, but it doesn't exist, fail.
          throw new HiveException(ErrorMsg.INVALID_PARTITION,
                StringUtils.join(partSpec.keySet(), ',') + " for table " + tbl.getTableName());

        }
        partitions.add(part);
      } else {
        // AbstractBaseAlterTableAnalyzer has already checked if partial partition specs are allowed,
        // thus we should not need to check it here.
        partitions = context.getDb().getPartitions(tbl, partSpec);
      }
    }

    return partitions;
  }
Operation process of running some alter table command that requires write id.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AbstractAlterTableOperation.java