private void clearInternalTableMetadata(
      long lastTime, TableOrphanFilesCleaningMetrics orphanFilesCleaningMetrics) {
    Set<String> validFiles = getValidMetadataFiles(table);
    LOG.info("Found {} valid metadata files for table {}", validFiles.size(), table.name());
    Pattern excludeFileNameRegex = getExcludeFileNameRegex(table);
    LOG.info(
        "Exclude metadata files with name pattern {} for table {}",
        excludeFileNameRegex,
        table.name());
    String metadataLocation = table.location() + File.separator + METADATA_FOLDER_NAME;
    LOG.info("start orphan files clean in {}", metadataLocation);

    try (AuthenticatedFileIO io = fileIO()) {
      if (io.supportPrefixOperations()) {
        SupportsPrefixOperations pio = io.asPrefixFileIO();
        Set<String> filesToDelete =
            deleteInvalidMetadataFile(
                pio, metadataLocation, lastTime, validFiles, excludeFileNameRegex);
        int deleted = TableFileUtil.deleteFiles(io, filesToDelete);

        runWithCondition(
            !filesToDelete.isEmpty(),
            () -> {
              LOG.info(
                  "Deleted {}/{} metadata files for table {}",
                  deleted,
                  filesToDelete.size(),
                  table.name());
              orphanFilesCleaningMetrics.completeOrphanMetadataFiles(filesToDelete.size(), deleted);
            });
      } else {
        LOG.warn(
            String.format(
                "Table %s doesn't support a fileIo with listDirectory or listPrefix, so skip clear files.",
                table.name()));
      }
    }
  }
Purge data older than the specified UTC timestamp

@param expirationConfig expiration configs
@param instant timestamp/timestampz/long field type uses UTC, others will use the local time
    zone
amoro-ams/src/main/java/org/apache/amoro/server/optimizing/maintainer/IcebergTableMaintainer.java