private Partition append_partition_common(RawStore ms, String dbName, String tableName,
List<String> part_vals, EnvironmentContext envContext) throws InvalidObjectException,
AlreadyExistsException, MetaException {
Partition part = new Partition();
boolean success = false, madeDir = false;
Path partLocation = null;
Table tbl = null;
try {
ms.openTransaction();
part.setDbName(dbName);
part.setTableName(tableName);
part.setValues(part_vals);
PreAddPartitionEvent event = new PreAddPartitionEvent(part, this);
firePreEvent(event);
MetaStoreUtils.validatePartitionNameCharacters(part_vals, partitionValidationPattern);
tbl = ms.getTable(part.getDbName(), part.getTableName());
if (tbl == null) {
throw new InvalidObjectException(
"Unable to add partition because table or database do not exist");
}
if (tbl.getSd().getLocation() == null) {
throw new MetaException(
"Cannot append a partition to a view");
}
part.setSd(tbl.getSd());
partLocation = new Path(tbl.getSd().getLocation(), Warehouse
.makePartName(tbl.getPartitionKeys(), part_vals));
part.getSd().setLocation(partLocation.toString());
Partition old_part = null;
try {
old_part = ms.getPartition(part.getDbName(), part
.getTableName(), part.getValues());
} catch (NoSuchObjectException e) {
// this means there is no existing partition