public static void setOutput(Job job, OutputJobInfo outputJobInfo) throws IOException {
    setOutput(job.getConfiguration(), job.getCredentials(), outputJobInfo);
  }
@Test
  public void testGetTableSchema() throws Exception {

    Configuration conf = new Configuration();
    Job job = Job.getInstance(conf, "test getTableSchema");
    HCatOutputFormat.setOutput(
        job,
        OutputJobInfo.create(
            dbName,
            tblName,
            new HashMap<String, String>() {{put("colname", "col_value");}}
        )
    );

    HCatSchema rowSchema = HCatOutputFormat.getTableSchema(job.getConfiguration());
    assertEquals("Row-schema should have exactly one column.",
        1, rowSchema.getFields().size());
    assertEquals("Row-schema must contain the data column.",
        "data_column", rowSchema.getFields().get(0).getName());
    assertEquals("Data column should have been STRING type.",
        serdeConstants.STRING_TYPE_NAME, rowSchema.getFields().get(0).getTypeString());

    HCatSchema tableSchema = HCatOutputFormat.getTableSchemaWithPartitionColumns(job.getConfiguration());
    assertEquals("Table-schema should have exactly 2 columns.",
        2, tableSchema.getFields().size());
    assertEquals("Table-schema must contain the data column.",
        "data_column", tableSchema.getFields().get(0).getName());
    assertEquals("Data column should have been STRING type.",
        serdeConstants.STRING_TYPE_NAME, tableSchema.getFields().get(0).getTypeString());
    assertEquals("Table-schema must contain the partition column.",
        "colname", tableSchema.getFields().get(1).getName());
    assertEquals("Partition column should have been STRING type.",
        serdeConstants.STRING_TYPE_NAME, tableSchema.getFields().get(1).getTypeString());

  }