public static boolean checkPrivilegeForMaterializedViews(List<Table> cachedMVTableList) throws HiveException {
    List<HivePrivilegeObject> privObjects = new ArrayList<HivePrivilegeObject>();

    for (Table cachedMVTable:cachedMVTableList) {
      List<String> colNames =
          cachedMVTable.getAllCols().stream()
              .map(FieldSchema::getName)
              .collect(Collectors.toList());

      HivePrivilegeObject privObject = new HivePrivilegeObject(cachedMVTable.getDbName(),
          cachedMVTable.getTableName(), colNames);
      privObjects.add(privObject);
    }

    try {
      SessionState.get().getAuthorizerV2().
          checkPrivileges(HiveOperationType.QUERY, privObjects, privObjects, new HiveAuthzContext.Builder().build());
    } catch (HiveException e) {
      if (e instanceof HiveAccessControlException) {
        return false;
      }
      throw e;
    }
    return true;
  }
Validate if given materialized view has SELECT privileges for current user
@param cachedMVTableList
@return false if user does not have privilege otherwise true
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveMaterializedViewUtils.java