@Override
public void updatePartitions(LensSessionHandle sessionid, String tblName, String storageName,
XPartitionList xPartitions) throws LensException {
try (SessionContext ignored = new SessionContext(sessionid)) {
CubeMetastoreClient client = getClient(sessionid);
Set<String> storageTableNames = getAllTablesForStorage(sessionid, tblName, storageName);
Map<UpdatePeriod, List<Partition>> partitionsToUpdate = new HashMap<>();
for (String storageTableName : storageTableNames) {
for (XPartition xPartition : xPartitions.getPartition()) {
Partition existingPartition = client.getPartitionByFilter(storageTableName,
StorageConstants.getPartFilter(JAXBUtils.getFullPartSpecAsMap(xPartition)));
JAXBUtils.updatePartitionFromXPartition(existingPartition, xPartition);
UpdatePeriod updatePeriod = UpdatePeriod.valueOf(xPartition.getUpdatePeriod().value());
List<Partition> partitionList = partitionsToUpdate.get(updatePeriod);
if (partitionList == null) {
partitionList = new ArrayList<>();
partitionsToUpdate.put(updatePeriod, partitionList);
}
partitionList.add(existingPartition);
}
}
client.updatePartitions(tblName, storageName, partitionsToUpdate);
} catch (HiveException | ClassNotFoundException | InvalidOperationException exc) {
throw new LensException(exc);
}
}