private static DataFile appendToLocalFile(Table table, File file, FileFormat format, StructLike partition,
      List<Record> records, Configuration conf)
      throws IOException {
    GenericAppenderFactory appenderFactory = new GenericAppenderFactory(table.schema());

    // Push down ORC related settings to appender
    if (FileFormat.ORC.equals(format)) {
      appenderFactory.setAll(conf.getValByRegex(ORC_CONFIG_PREFIX));
    }

    FileAppender<Record> appender = appenderFactory.newAppender(
        Files.localOutput(file), format);
    try (FileAppender<Record> fileAppender = appender) {
      fileAppender.addAll(records);
    }

    return DataFiles.builder(table.spec())
        .withRecordCount(records.size())
        .withFileSizeInBytes(file.length())
        .withPath(Files.localInput(file).location())
        .withMetrics(appender.metrics())
        .withFormat(format)
        .withPartition(partition)
        .withSplitOffsets(appender.splitOffsets())
        .build();
  }
Helper for appending {@link DataFile} to a table or appending {@link Record}s to a table.
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/data/GenericAppenderHelper.java