public static Partition filterPartitionIfEnabled(
      boolean isFilterEnabled,
      MetaStoreFilterHook filterHook, Partition p) throws MetaException, NoSuchObjectException {

    if (isFilterEnabled) {
      Partition filteredPartition = filterHook.filterPartition(p);

      if (filteredPartition == null) {
        throw new NoSuchObjectException("Partition in " + p.getCatName() + CATALOG_DB_SEPARATOR + p.getDbName() + "." +
            p.getTableName() + " not found.");
      }
    }

    return p;
  }
Filter the partition if filtering is enabled. Otherwise, return original object
@param isFilterEnabled true: filtering is enabled; false: filtring is disabled.
@param filterHook: the object that does filtering
@param p: the partition object
@return the partition object that user has access or original list if filtering is disabled;
        Otherwise, throw NoSuchObjectException
@throws MetaException
@throws NoSuchObjectException
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FilterUtils.java