private static void cleanExtraOutputFiles(
      TrinoFileSystem fileSystem, String queryId, String location, Set<String> fileNamesToKeep) {
    checkArgument(!queryId.contains("-"), "query ID should not contain hyphens: %s", queryId);

    Deque<String> filesToDelete = new ArrayDeque<>();
    try {
      log.debug("Deleting failed attempt files from %s for query %s", location, queryId);

      FileIterator iterator = fileSystem.listFiles(location);
      while (iterator.hasNext()) {
        FileEntry entry = iterator.next();
        String name = fileName(entry.path());
        if (name.startsWith(queryId + "-") && !fileNamesToKeep.contains(name)) {
          filesToDelete.add(name);
        }
      }

      if (filesToDelete.isEmpty()) {
        return;
      }

      log.info(
          "Found %s files to delete and %s to retain in location %s for query %s",
          filesToDelete.size(), fileNamesToKeep.size(), location, queryId);
      ImmutableList.Builder<String> deletedFilesBuilder = ImmutableList.builder();
      Iterator<String> filesToDeleteIterator = filesToDelete.iterator();
      List<String> deleteBatch = new ArrayList<>();
      while (filesToDeleteIterator.hasNext()) {
        String fileName = filesToDeleteIterator.next();
        deletedFilesBuilder.add(fileName);
        filesToDeleteIterator.remove();

        deleteBatch.add(location + "/" + fileName);
        if (deleteBatch.size() >= DELETE_BATCH_SIZE) {
          log.debug("Deleting failed attempt files %s for query %s", deleteBatch, queryId);
          fileSystem.deleteFiles(deleteBatch);
          deleteBatch.clear();
        }
      }

      if (!deleteBatch.isEmpty()) {
        log.debug("Deleting failed attempt files %s for query %s", deleteBatch, queryId);
        fileSystem.deleteFiles(deleteBatch);
      }

      List<String> deletedFiles = deletedFilesBuilder.build();
      if (!deletedFiles.isEmpty()) {
        log.info(
            "Deleted failed attempt files %s from %s for query %s",
            deletedFiles, location, queryId);
      }
    } catch (IOException e) {
      throw new TrinoException(
          ICEBERG_FILESYSTEM_ERROR,
          format("Could not clean up extraneous output files; remaining files: %s", filesToDelete),
          e);
    }
  }
Iceberg original metadata has some problems for mixed-format table, such as iceberg version,
table type. So copy from IcebergMetadata and made some change
amoro-format-mixed/amoro-mixed-trino/src/main/java/org/apache/amoro/trino/unkeyed/IcebergMetadata.java