code: public static List<String> generateCreatePartitionDDL(String dbName, String tableName, String partitionLocation,
        Map<String, String> partitionsDMLInfo, Optional<String> format) {
  
      if (null == partitionsDMLInfo || partitionsDMLInfo.size() == 0) {
        return Collections.emptyList();
      }
  
      // Partition details
      StringBuilder partitionSpecs = new StringBuilder();
      partitionSpecs.append("PARTITION (");
      boolean isFirstPartitionSpec = true;
      for (Map.Entry<String, String> partition : partitionsDMLInfo.entrySet()) {
        if (isFirstPartitionSpec) {
          isFirstPartitionSpec = false;
        } else {
          partitionSpecs.append(", ");
        }
        partitionSpecs.append(String.format("`%s`='%s'", partition.getKey(), partition.getValue()));
      }
      partitionSpecs.append(") \n");
  
      // Create statement
      List<String> ddls = Lists.newArrayList();
      // Note: Hive does not support fully qualified Hive table names such as db.table for ALTER TABLE in v0.13
      // .. hence specifying 'use dbName' as a precursor to rename
      // Refer: HIVE-2496
      ddls.add(String.format("USE %s%n", dbName));
      if (format.isPresent()) {
        ddls.add(String
            .format("ALTER TABLE `%s` ADD IF NOT EXISTS %s FILEFORMAT %s LOCATION '%s' ", tableName, partitionSpecs,
                format.get(), partitionLocation));
      } else {
        ddls.add(String.format("ALTER TABLE `%s` ADD IF NOT EXISTS %s LOCATION '%s' ", tableName, partitionSpecs,
            partitionLocation));
      }
  
      return ddls;
    }
docs: *
  Generate DDL query to create a Hive partition pointing at specific location.
  @param dbName Hive database name.
  @param tableName Hive table name.
  @param partitionLocation Physical location of partition.
  @param partitionsDMLInfo Partitions DML info - a map of partition name and partition value.
  @param format Hive partition file format
  @return Commands to create a partition.