public static GetLatestCommittedCompactionInfoResponse filterCommittedCompactionInfoStructIfEnabled(
      boolean isFilterEnabled, MetaStoreFilterHook filterHook,
      String catName, String dbName, String tableName, GetLatestCommittedCompactionInfoResponse response
  ) throws MetaException {
    if (isFilterEnabled && response.getCompactionsSize() > 0) {
      List<CompactionInfoStruct> compactions = response.getCompactions();
      if (compactions.get(0).getPartitionname() == null) {
        // non partitioned table
        List<String> tableNames = new ArrayList<>();
        tableNames.add(tableName);
        tableNames = filterHook.filterTableNames(catName, dbName, tableNames);
        if (tableNames.isEmpty()) {
          response.unsetCompactions();
        }
      } else {
        // partitioned table
        List<String> partitionNames = compactions.stream()
            .map(CompactionInfoStruct::getPartitionname)
            .collect(Collectors.toList());
        partitionNames = filterHook.filterPartitionNames(
            catName, dbName, tableName, partitionNames);
        Set<String> partitionNameSet = new HashSet<>(partitionNames);
        compactions = compactions.stream()
            .filter(lci -> partitionNameSet.contains(lci.getPartitionname()))
            .collect(Collectors.toList());
        response.setCompactions(compactions);
      }
    }
    return response;
  }
Filter the list of compactions if filtering is enabled. Otherwise, return original list

@param isFilterEnabled true: filtering is enabled; false: filtering is disabled.
@param filterHook      the object that does filtering
@param compactions     the list of compactions
@return the list of compactions that user has access or original list if filtering is disabled;
@throws MetaException
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FilterUtils.java