@Test
  public void testConvertBooleanToInt() throws Exception {
    String tbl = "test_convert_boolean_to_int";
    String inputFileName = TEST_DATA_DIR + "/testConvertBooleanToInt/data.txt";
    File inputDataDir = new File(inputFileName).getParentFile();
    inputDataDir.mkdir();

    String[] lines = new String[]{"llama\ttrue", "alpaca\tfalse"};
    HcatTestUtils.createTestDataFile(inputFileName, lines);

    driver.run("drop table if exists " + tbl);
    driver.run("create external table " + tbl +
        " (a string, b boolean) row format delimited fields terminated by '\t'" +
        " stored as textfile location 'file:///" + inputDataDir.getPath().replaceAll("\\\\", "/") + "'");

    Properties properties = new Properties();
    properties.setProperty(HCatConstants.HCAT_DATA_CONVERT_BOOLEAN_TO_INTEGER, "true");
    properties.put("stop.on.failure", Boolean.TRUE.toString());
    PigServer server = createPigServer(true, properties);
    server.registerQuery(
      "data = load 'test_convert_boolean_to_int' using org.apache.hive.hcatalog.pig.HCatLoader();");
    Schema schema = server.dumpSchema("data");
    assertEquals(2, schema.getFields().size());

    assertEquals("a", schema.getField(0).alias);
    assertEquals(DataType.CHARARRAY, schema.getField(0).type);
    assertEquals("b", schema.getField(1).alias);
    if (PigHCatUtil.pigHasBooleanSupport()){
      assertEquals(DataType.BOOLEAN, schema.getField(1).type);
    } else {
      assertEquals(DataType.INTEGER, schema.getField(1).type);
    }

    Iterator<Tuple> iterator = server.openIterator("data");
    Tuple t = iterator.next();
    assertEquals("llama", t.get(0));
    assertEquals(1, t.get(1));
    t = iterator.next();
    assertEquals("alpaca", t.get(0));
    assertEquals(0, t.get(1));
    assertFalse(iterator.hasNext());
  }
Simulates Pig relying on HCatLoader to inform about input size of multiple tables.
@throws Exception
hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/AbstractHCatLoaderTest.java