private static IMetaStoreClient getHiveMetaClient(String serverUri,
                             String serverKerberosPrincipal,
                             Class<?> clazz,
                             Job job) throws Exception {

    // The job configuration is passed in so the configuration will be cloned
    // from the pig job configuration. This is necessary for overriding
    // metastore configuration arguments like the metastore jdbc connection string
    // and password, in the case of an embedded metastore, which you get when
    // hive.metastore.uris = "".
    HiveConf hiveConf = new HiveConf(job.getConfiguration(), clazz);

    if (serverUri != null) {
      hiveConf.setVar(HiveConf.ConfVars.METASTORE_URIS, serverUri.trim());
    }

    if (serverKerberosPrincipal != null) {
      hiveConf.setBoolVar(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL, true);
      hiveConf.setVar(HiveConf.ConfVars.METASTORE_KERBEROS_PRINCIPAL, serverKerberosPrincipal);
    }

    try {
      return HCatUtil.getHiveMetastoreClient(hiveConf);
    } catch (Exception e) {
      throw new Exception("Could not instantiate a HiveMetaStoreClient connecting to server uri:[" + serverUri + "]", e);
    }
  }
Determine if the current Pig version supports boolean columns. This works around a
dependency conflict preventing HCatalog from requiring a version of Pig with boolean
field support and should be removed once HCATALOG-466 has been resolved.
hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/PigHCatUtil.java