if (dynamicPartVals != null){
// dynamic part vals specified
List<String> dynamicPartKeys = jobInfo.getTableInfo().getDynamicPartitioningKeys();
if (dynamicPartVals.size() != dynamicPartKeys.size()){
throw new HCatException(ErrorType.ERROR_INVALID_PARTITION_VALUES,
"Unable to instantiate dynamic partitioning storage driver, mismatch between"
+ " number of partition values obtained["+dynamicPartVals.size()
+ "] and number of partition values required["+dynamicPartKeys.size()+"]");
}
for (int i = 0; i < dynamicPartKeys.size(); i++){
partitionValues.put(dynamicPartKeys.get(i), dynamicPartVals.get(i));
}
// re-home location, now that we know the rest of the partvals
Table table = jobInfo.getTable();
List<String> partitionCols = new ArrayList<String>();
for(FieldSchema schema : table.getPartitionKeys()) {
partitionCols.add(schema.getName());
}
location = driver.getOutputLocation(jobContext,
table.getSd().getLocation() , partitionCols,
partitionValues,jobContext.getConfiguration().get(HCatConstants.HCAT_DYNAMIC_PTN_JOBID));
}
//Initialize the storage driver
driver.setSchema(jobContext, jobInfo.getOutputSchema());
driver.setPartitionValues(jobContext, partitionValues);
driver.setOutputPath(jobContext, location);
// HCatUtil.logMap(LOG,"Setting outputPath ["+location+"] for ",partitionValues);
driver.initialize(jobContext, jobInfo.getStorerInfo().getProperties());
return driver;
} catch(Exception e) {
if (e instanceof HCatException){
throw (HCatException)e;
}else{
throw new HCatException(ErrorType.ERROR_INIT_STORAGE_DRIVER, e);
}
}
}