@Test
  public void testReadDataFromEncryptedHiveTableByHCatMR() throws Exception {
    assumeTrue(!TestUtil.shouldSkip(storageFormat, DISABLED_STORAGE_FORMATS));

    readRecords.clear();
    Configuration conf = new Configuration();
    Job job = new Job(conf, "hcat mapreduce read encryption test");
    job.setJarByClass(this.getClass());
    job.setMapperClass(TestHCatLoaderEncryption.MapRead.class);

    // input/output settings
    job.setInputFormatClass(HCatInputFormat.class);
    job.setOutputFormatClass(TextOutputFormat.class);

    HCatInputFormat.setInput(job, Warehouse.DEFAULT_DATABASE_NAME, ENCRYPTED_TABLE, null);

    job.setMapOutputKeyClass(BytesWritable.class);
    job.setMapOutputValueClass(Text.class);

    job.setNumReduceTasks(0);

    FileSystem fs = new LocalFileSystem();
    String pathLoc = TEST_DATA_DIR + "/testHCatMREncryptionOutput";
    Path path = new Path(pathLoc);
    if (fs.exists(path)) {
      fs.delete(path, true);
    }

    TextOutputFormat.setOutputPath(job, new Path(pathLoc));

    job.waitForCompletion(true);

    int numTuplesRead = 0;
    for (HCatRecord hCatRecord : readRecords) {
      assertEquals(2, hCatRecord.size());
      assertNotNull(hCatRecord.get(0));
      assertNotNull(hCatRecord.get(1));
      assertTrue(hCatRecord.get(0).getClass() == Integer.class);
      assertTrue(hCatRecord.get(1).getClass() == String.class);
      assertEquals(hCatRecord.get(0), basicInputData.get(numTuplesRead).first);
      assertEquals(hCatRecord.get(1), basicInputData.get(numTuplesRead).second);
      numTuplesRead++;
    }
    assertEquals("failed HCat MR read with storage format: " + this.storageFormat,
        basicInputData.size(), numTuplesRead);
  }
Execute Hive CLI statement
@param cmd arbitrary statement to execute
hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderEncryption.java