public static String partitionDescriptor(Map<String,String> ptnDesc) {
    StringBuilder sb = new StringBuilder();
    if ((ptnDesc != null) && (!ptnDesc.isEmpty())){
      boolean first = true;
      sb.append(" PARTITION (");
      for (Map.Entry e : ptnDesc.entrySet()){
        if (!first){
          sb.append(", ");
        } else {
          first = false;
        }
        sb.append(e.getKey()); // TODO : verify if any quoting is needed for keys
        sb.append('=');
        sb.append('"');
        sb.append(e.getValue()); // TODO : verify if any escaping is needed for values
        sb.append('"');
      }
      sb.append(')');
    }
    return sb.toString();
  }
Return a mapping from a given map function if available, and the key itself if not.
hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/repl/ReplicationUtils.java