@Override
public int addPartitions(List<HCatAddPartitionDesc> partInfoList)
throws HCatException {
int numPartitions = -1;
if ((partInfoList == null) || (partInfoList.size() == 0)) {
throw new HCatException("The partition list is null or empty.");
}
Table tbl = null;
try {
tbl = hmsClient.getTable(partInfoList.get(0).getDatabaseName(),
partInfoList.get(0).getTableName());
HCatTable hcatTable = new HCatTable(tbl);
ArrayList<Partition> ptnList = new ArrayList<Partition>();
for (HCatAddPartitionDesc desc : partInfoList) {
HCatPartition hCatPartition = desc.getHCatPartition();
// TODO: Remove in Hive 0.16.
// This is required only to support the deprecated HCatAddPartitionDesc.Builder interfaces.
if (hCatPartition == null) {
hCatPartition = desc.getHCatPartition(hcatTable);
}
ptnList.add(hCatPartition.toHivePartition());
}
numPartitions = hmsClient.add_partitions(ptnList);
} catch (InvalidObjectException e) {
throw new HCatException(
"InvalidObjectException while adding partition.", e);
} catch (AlreadyExistsException e) {
throw new HCatException(
"AlreadyExistsException while adding partition.", e);
} catch (MetaException e) {
throw new HCatException("MetaException while adding partition.", e);
} catch (NoSuchObjectException e) {
throw new ObjectNotFoundException("The table "
+ partInfoList.get(0).getTableName()
+ " is could not be found.", e);
} catch (TException e) {