private static void testReadDataPrimitiveTypes() throws Exception {
      // testConvertBooleanToInt() sets HCatConstants.HCAT_DATA_CONVERT_BOOLEAN_TO_INTEGER=true, and
      // might be the last one to call HCatContext.INSTANCE.setConf(). Make sure setting is false.
      Properties properties = new Properties();
      properties.setProperty(HCatConstants.HCAT_DATA_CONVERT_BOOLEAN_TO_INTEGER, "false");
      PigServer server = createPigServer(false, properties);
      server.registerQuery("X = load '" + ALL_PRIMITIVE_TYPES_TABLE + "' using " + HCatLoader.class.getName() + "();");
      Iterator<Tuple> XIter = server.openIterator("X");
      int numTuplesRead = 0;
      while (XIter.hasNext()) {
        Tuple t = XIter.next();
        assertEquals(HCatFieldSchema.Type.numPrimitiveTypes(), t.size());
        int colPos = 0;
        for (Object referenceData : primitiveRows[numTuplesRead]) {
          if (referenceData == null) {
            assertTrue("rowNum=" + numTuplesRead + " colNum=" + colPos
                + " Reference data is null; actual "
                + t.get(colPos), t.get(colPos) == null);
          } else if (referenceData instanceof Date) {
            // Note that here we ignore nanos part of Hive Timestamp since nanos are dropped when
            // reading Hive from Pig by design.
            assertTrue("rowNum=" + numTuplesRead + " colNum=" + colPos
                    + " Reference data=" + ((Date)referenceData).toEpochMilli()
                    + " actual=" + ((DateTime)t.get(colPos)).getMillis()
                    + "; types=(" + referenceData.getClass() + "," + t.get(colPos).getClass() + ")",
                ((Date)referenceData).toEpochMilli() == ((DateTime)t.get(colPos)).getMillis());
          } else if (referenceData instanceof Timestamp) {
            // Note that here we ignore nanos part of Hive Timestamp since nanos are dropped when
            // reading Hive from Pig by design.
            assertTrue("rowNum=" + numTuplesRead + " colNum=" + colPos
                + " Reference data=" + ((Timestamp)referenceData).toEpochMilli()
                + " actual=" + ((DateTime)t.get(colPos)).getMillis()
                + "; types=(" + referenceData.getClass() + "," + t.get(colPos).getClass() + ")",
                ((Timestamp)referenceData).toEpochMilli()== ((DateTime)t.get(colPos)).getMillis());
          } else {
            // Doing String comps here as value objects in Hive in Pig are different so equals()
            // doesn't work.
            assertTrue("rowNum=" + numTuplesRead + " colNum=" + colPos
                + " Reference data=" + referenceData + " actual=" + t.get(colPos)
                + "; types=(" + referenceData.getClass() + "," + t.get(colPos).getClass() + ") ",
                referenceData.toString().equals(t.get(colPos).toString()));
          }
          colPos++;
        }
        numTuplesRead++;
      }
      assertTrue("Expected " + primitiveRows.length + "; found " + numTuplesRead, numTuplesRead == primitiveRows.length);
    }
Test that value from Hive table are read properly in Pig
hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/AbstractHCatLoaderTest.java