public static void appendFiles(URI fromURI, String format, Table icebergTbl, boolean isOverwrite,
      Map<String, String> partitionSpec, Configuration conf) throws SemanticException {
    try {
      Transaction transaction = icebergTbl.newTransaction();
      if (isOverwrite) {
        DeleteFiles delete = transaction.newDelete();
        if (partitionSpec != null) {
          for (Map.Entry<String, String> part : partitionSpec.entrySet()) {
            final Type partKeyType = icebergTbl.schema().findType(part.getKey());
            final Object partKeyVal = Conversions.fromPartitionString(partKeyType, part.getValue());
            delete.deleteFromRowFilter(Expressions.equal(part.getKey(), partKeyVal));
          }
        } else {
          delete.deleteFromRowFilter(Expressions.alwaysTrue());
        }
        delete.commit();
      }

      MetricsConfig metricsConfig = MetricsConfig.fromProperties(icebergTbl.properties());
      PartitionSpec spec = icebergTbl.spec();
      String nameMappingStr = icebergTbl.properties().get(TableProperties.DEFAULT_NAME_MAPPING);
      NameMapping nameMapping = null;
      if (nameMappingStr != null) {
        nameMapping = NameMappingParser.fromJson(nameMappingStr);
      }
      AppendFiles append = transaction.newAppend();
      Map<String, String> actualPartitionSpec = Optional.ofNullable(partitionSpec).orElse(Collections.emptyMap());
      String actualFormat = Optional.ofNullable(format).orElse(IOConstants.PARQUET).toLowerCase();
      RemoteIterator<LocatedFileStatus> iterator = getFilesIterator(new Path(fromURI), conf);
      List<DataFile> dataFiles =
          getDataFiles(iterator, actualPartitionSpec, actualFormat, spec, metricsConfig, nameMapping, conf);
      dataFiles.forEach(append::appendFile);
      append.commit();
      transaction.commitTransaction();
    } catch (Exception e) {
      throw new SemanticException("Can not append data files", e);
    }
  }
Import files from given partitions to an Iceberg table.
@param sourceLocation location of the HMS table
@param format inputformat class name of the HMS table
@param partitionSpecProxy  list of HMS table partitions wrapped in partitionSpecProxy
@param partitionKeys list of partition keys
@param icebergTableProperties destination iceberg table properties
@param conf a Hadoop configuration
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveTableUtil.java