Source:
private void testAddPartitions(URI uri, String tableName, List<String> partitionNames) throws Exception { List<CatalogProtos.PartitionDescProto> partitions = TUtil.newList(); for (String partitionName : partitionNames) { CatalogProtos.PartitionDescProto.Builder builder = CatalogProtos.PartitionDescProto.newBuilder(); builder.setPartitionName(partitionName); Path path = new Path(uri.getPath(), partitionName); builder.setPath(path.toString()); List<PartitionKeyProto> partitionKeyList = new ArrayList<>(); String[] split = partitionName.split("/"); for (String aSplit : split) { String[] eachPartitionName = aSplit.split("="); PartitionKeyProto.Builder keyBuilder = PartitionKeyProto.newBuilder(); keyBuilder.setColumnName(eachPartitionName[0]); keyBuilder.setPartitionValue(eachPartitionName[1]); partitionKeyList.add(keyBuilder.build()); } builder.addAllPartitionKeys(partitionKeyList); partitions.add(builder.build()); } store.addPartitions(DB_NAME, tableName, partitions, true); for (String partitionName : partitionNames) { CatalogProtos.PartitionDescProto resultDesc = store.getPartition(DB_NAME, NATION, partitionName); assertNotNull(resultDesc); assertEquals(resultDesc.getPartitionName(), partitionName); assertEquals(resultDesc.getPath(), uri.toString() + "/" + partitionName); assertEquals(resultDesc.getPartitionKeysCount(), 2); String[] split = partitionName.split("/"); for (int i = 0; i < resultDesc.getPartitionKeysCount(); i++) { CatalogProtos.PartitionKeyProto keyProto = resultDesc.getPartitionKeys(i); String[] eachName = split[i].split("="); assertEquals(keyProto.getPartitionValue(), eachName[1]); } } }

Target:
private void testAddPartitions(URI uri, String tableName, List<String> partitionNames) throws Exception { List<CatalogProtos.PartitionDescProto> partitions = new ArrayList<>(); for (String partitionName : partitionNames) { CatalogProtos.PartitionDescProto.Builder builder = CatalogProtos.PartitionDescProto.newBuilder(); builder.setPartitionName(partitionName); Path path = new Path(uri.getPath(), partitionName); builder.setPath(path.toString()); List<PartitionKeyProto> partitionKeyList = new ArrayList<>(); String[] splits = partitionName.split("/"); for (String aSplit : splits) { String[] eachPartitionName = aSplit.split("="); PartitionKeyProto.Builder keyBuilder = PartitionKeyProto.newBuilder(); keyBuilder.setColumnName(eachPartitionName[0]); keyBuilder.setPartitionValue(eachPartitionName[1]); partitionKeyList.add(keyBuilder.build()); } builder.addAllPartitionKeys(partitionKeyList); partitions.add(builder.build()); } store.addPartitions(DB_NAME, tableName, partitions, true); for (String partitionName : partitionNames) { CatalogProtos.PartitionDescProto resultDesc = store.getPartition(DB_NAME, NATION, partitionName); assertNotNull(resultDesc); assertEquals(resultDesc.getPartitionName(), partitionName); assertEquals(resultDesc.getPath(), uri.toString() + "/" + partitionName); assertEquals(resultDesc.getPartitionKeysCount(), 2); String[] split = partitionName.split("/"); for (int i = 0; i < resultDesc.getPartitionKeysCount(); i++) { CatalogProtos.PartitionKeyProto keyProto = resultDesc.getPartitionKeys(i); String[] eachName = split[i].split("="); assertEquals(keyProto.getPartitionValue(), eachName[1]); } } }