@Override
  public List<Table> getAllMaterializedViewObjectsForRewriting(String catName) throws MetaException {
    List<Table> allMaterializedViews = new ArrayList<>();
    boolean commited = false;
    Query query = null;
    try {
      openTransaction();
      catName = normalizeIdentifier(catName);
      query = pm.newQuery(MTable.class);
      query.setFilter("database.catalogName == catName && tableType == tt && rewriteEnabled == re");
      query.declareParameters("java.lang.String catName, java.lang.String tt, boolean re");
      Collection<MTable> mTbls = (Collection<MTable>) query.executeWithArray(
          catName, TableType.MATERIALIZED_VIEW.toString(), true);
      for (MTable mTbl : mTbls) {
        Table tbl = convertToTable(mTbl);
        tbl.setCreationMetadata(
            convertToCreationMetadata(
                getCreationMetadata(tbl.getCatName(), tbl.getDbName(), tbl.getTableName())));
        allMaterializedViews.add(tbl);
      }
      commited = commitTransaction();
    } finally {
      rollbackAndCleanup(commited, query);
    }
    return allMaterializedViews;
  }
Convert PrivilegeGrantInfo from privMap to MTablePrivilege, and add all of
them to the toPersistPrivObjs. These privilege objects will be persisted as
part of createTable.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java