public static boolean shouldIncludeForCompaction(Table table, String partitionPath, ContentFile<?> file) {
    return !table.spec().isPartitioned() ||
        partitionPath == null && file.specId() != table.spec().specId() ||
        partitionPath != null &&
            table.specs().get(file.specId()).partitionToPath(file.partition()).equals(partitionPath);
  }
This method implements a common filter that is used in several places in Iceberg compaction code.
Its aim is to determine if the provided file needs to be handled when compacting a partition whose path is equal to
the provided partitionPath. Returns true when one of the following conditions is true, otherwise returns false:
 1. table is unpartitioned
 2. partitionPath is null and the file belongs to the non-latest partition spec
 3. partitionPath is not null and the file belongs to the partition whose path is the partitionPath
@param table the iceberg table
@param partitionPath partition path
@param file Data or Delete file
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/compaction/IcebergCompactionUtil.java