@Test
public void testCreateTableLike() throws Exception {

  HCatClient client = HCatClient.create(new Configuration(hcatConf));
  String tableName = "tableone";
  String cloneTable = "tabletwo";
  client.dropTable(null, tableName, true);
  client.dropTable(null, cloneTable, true);
  ArrayList<HCatFieldSchema> cols = new ArrayList<HCatFieldSchema>();
  cols.add(new HCatFieldSchema("id", Type.INT, "id columns"));
  cols.add(new HCatFieldSchema("value", Type.STRING, "id columns"));
  HCatCreateTableDesc tableDesc = HCatCreateTableDesc
    .create(null, tableName, cols).fileFormat("rcfile").build();
  client.createTable(tableDesc);
  // create a new table similar to previous one.
  client.createTableLike(null, tableName, cloneTable, true, false, null);
  List<String> tables = client.listTableNamesByPattern(null, "table*");
  assertTrue(tables.size() == 2);
  client.close();
}