public static DeleteFile createPositionalDeleteFile(Table table, String deleteFilePath, FileFormat fileFormat,
      Map<String, Object> partitionValues, List<PositionDelete<Record>> deletes) throws IOException {

    Schema posDeleteRowSchema = deletes.get(0).row() == null ? null : table.schema();
    FileAppenderFactory<Record> appenderFactory = new GenericAppenderFactory(table.schema(), table.spec(),
        null, null, posDeleteRowSchema);
    EncryptedOutputFile outputFile = table.encryption().encrypt(HadoopOutputFile.fromPath(
        new org.apache.hadoop.fs.Path(table.location(), deleteFilePath), new Configuration()));

    PartitionKey partitionKey = null;
    if (partitionValues != null) {
      Record record = GenericRecord.create(table.schema()).copy(partitionValues);
      partitionKey = new PartitionKey(table.spec(), table.schema());
      partitionKey.partition(record);
    }

    PositionDeleteWriter<Record> posWriter = appenderFactory.newPosDeleteWriter(outputFile, fileFormat, partitionKey);
    try (PositionDeleteWriter<Record> writer = posWriter) {
      deletes.forEach(del -> {
        PositionDelete positionDelete = PositionDelete.create();
        positionDelete.set(del.path(), del.pos(), del.row());
        writer.write(positionDelete);
      });
    }
    return posWriter.toDeleteFile();
  }
@param table The table to create the delete file for
@param deleteFilePath The path where the delete file should be created, relative to the table location root
@param fileFormat The file format that should be used for writing out the delete file
@param partitionValues A map of partition values (partitionKey=partitionVal, ...) to be used for the delete file
@param deletes The list of position deletes, each containing the data file path, the position of the row in the
               data file and the row itself that should be deleted
@return The DeleteFile created
@throws IOException If there is an error during DeleteFile write
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergTestUtils.java