@Test
  public void testReadWrite() throws Exception {
    final String tblName = "small_ints_table";
    final String tblName2 = "pig_hcatalog_1";
    File dataDir = new File(TEST_DATA_DIR + File.separator + "testReadWrite");
    FileUtil.fullyDelete(dataDir); // Might not exist
    Assert.assertTrue(dataDir.mkdir());
    final String INPUT_FILE_NAME = dataDir + "/inputtrw.data";

    AbstractHCatLoaderTest.dropTable(tblName, driver);
    HcatTestUtils.createTestDataFile(INPUT_FILE_NAME, new String[]{"40\t1"});

    AbstractHCatLoaderTest.executeStatementOnDriver("create external table " + tblName +
      " (my_small_int smallint, my_tiny_int tinyint)" +
      " row format delimited fields terminated by '\t' stored as textfile location '" +
      dataDir.toURI().getPath() + "'", driver);
    AbstractHCatLoaderTest.dropTable(tblName2, driver);
    AbstractHCatLoaderTest.createTableDefaultDB(tblName2, "my_small_int smallint, " +
            "my_tiny_int " + "tinyint", null, driver, "textfile");

    LOG.debug("File=" + INPUT_FILE_NAME);
    TestHCatStorer.dumpFile(INPUT_FILE_NAME);
    PigServer server = createPigServer(true);
    try {
      int queryNumber = 1;
      logAndRegister(server,
        "A = load '" + tblName +
          "' using org.apache.hive.hcatalog.pig.HCatLoader() as (my_small_int:int, my_tiny_int:int);",
        queryNumber++);
      logAndRegister(server,
        "b = foreach A generate my_small_int + my_tiny_int as my_small_int, my_tiny_int;",
        queryNumber++);
      logAndRegister(server, "store b into '" + tblName2 +
        "' using org.apache.hive.hcatalog.pig.HCatStorer();", queryNumber);
      //perform simple checksum here; make sure nothing got turned to NULL
      AbstractHCatLoaderTest.executeStatementOnDriver("select my_small_int from " + tblName2, driver);
      ArrayList l = new ArrayList();
      driver.getResults(l);
      for(Object t : l) {
        LOG.debug("t=" + t);
      }
      Assert.assertEquals("Expected '1' rows; got '" + l.size() + "'", 1, l.size());
      int result = Integer.parseInt((String)l.get(0));
      Assert.assertEquals("Expected value '41'; got '" + result + "'", 41, result);
    }
    finally {
      server.shutdown();
    }
  }
Test round trip of smallint/tinyint: Hive->Pig->Hive.  This is a more general use case in HCatalog:
'read some data from Hive, process it in Pig, write result back to a Hive table'
hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java