private void checkPartitionedOrphanFilesAndDelete(boolean isUnPartitioned) {
    List<String> partitionsToCheck = Lists.newArrayList();
    if (isUnPartitioned) {
      partitionsToCheck.add(this.unpartitionTableLocation);
    } else {
      partitionsToCheck.addAll(
          this.partitionToCreate.values().stream()
              .map(partition -> partition.getSd().getLocation())
              .collect(Collectors.toList()));
      partitionsToCheck.addAll(
          this.partitionToAlterLocation.values().stream()
              .map(partition -> partition.getSd().getLocation())
              .collect(Collectors.toList()));
    }
    Set<String> addFilesPathCollect =
        addFiles.stream().map(dataFile -> dataFile.path().toString()).collect(Collectors.toSet());
    Set<String> deleteFilesPathCollect =
        deleteFiles.stream()
            .map(deleteFile -> deleteFile.path().toString())
            .collect(Collectors.toSet());

    for (String partitionLocation : partitionsToCheck) {
      try (AuthenticatedHadoopFileIO io = table.io()) {
        io.listPrefix(partitionLocation)
            .forEach(
                f -> {
                  if (!addFilesPathCollect.contains(f.location())
                      && !deleteFilesPathCollect.contains(f.location())) {
                    io.deleteFile(f.location());
                    LOG.warn("Delete orphan file path: {}", f.location());
                  }
                });
      }
    }
  }
check files in the partition, and delete orphan files
amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/amoro/hive/op/UpdateHiveFiles.java