dbName, tableName, null));
// initialize HCatOutputFormat
HCatOutputFormat.setOutput(job, OutputJobInfo.create(
dbName, outputTableName, outputPartitionKvps));
// test with and without specifying schema randomly
HCatSchema s = HCatInputFormat.getTableSchema(job);
if (writeToNonPartPigTable) {
List<HCatFieldSchema> newHfsList = new ArrayList<HCatFieldSchema>();
// change smallint and tinyint to int
for (HCatFieldSchema hfs : s.getFields()) {
if (hfs.getTypeString().equals("smallint")) {
newHfsList.add(new HCatFieldSchema(hfs.getName(),
HCatFieldSchema.Type.INT, hfs.getComment()));
} else if (hfs.getTypeString().equals("tinyint")) {
newHfsList.add(new HCatFieldSchema(hfs.getName(),
HCatFieldSchema.Type.INT, hfs.getComment()));
} else {
newHfsList.add(hfs);
}
}
s = new HCatSchema(newHfsList);
}
HCatOutputFormat.setSchema(job, s);
job.setInputFormatClass(HCatInputFormat.class);