HiveConf hiveConf = new HiveConf(conf, HiveApiOutputCommitter.class);
String dbName = outputDesc.getDbName();
String tableName = outputDesc.getTableName();
HiveMetaStoreClient client;
Table hiveTable;
try {
client = new HiveMetaStoreClient(hiveConf);
hiveTable = client.getTable(dbName, tableName);
// CHECKSTYLE: stop IllegalCatch
} catch (Exception e) {
// CHECKSTYLE: resume IllegalCatch
throw new IOException(e);
}
Partition partition = new Partition();
partition.setDbName(dbName);
partition.setTableName(tableName);
partition.setParameters(outputInfo.getTableParams());
List<String> partitionValues = HiveUtils
.orderedPartitionValues(hiveTable.getPartitionKeys(),
outputDesc.getPartitionValues());
partition.setValues(partitionValues);
StorageDescriptor sd = new StorageDescriptor(hiveTable.getSd());
sd.setParameters(outputInfo.getSerializerParams());
sd.setLocation(outputInfo.getFinalOutputPath());
sd.setCols(outputInfo.getColumnInfo());
partition.setSd(sd);
try {
client.add_partition(partition);
// CHECKSTYLE: stop IllegalCatch
} catch (Exception e) {
// CHECKSTYLE: resume IllegalCatch
throw new IOException(e);
}