@Override
  public List<Table> getTableObjectsByName(String catName, String db, List<String> tbl_names,
      GetProjectionsSpec projectionSpec, String tablePattern) throws MetaException, UnknownDBException {
    List<Table> tables = new ArrayList<>();
    boolean committed = false;
    Query query = null;
    List<MTable> mtables = null;

    try {
      openTransaction();
      db = normalizeIdentifier(db);
      catName = normalizeIdentifier(catName);

      List<String> lowered_tbl_names = new ArrayList<>();
      if(tbl_names != null) {
        lowered_tbl_names = new ArrayList<>(tbl_names.size());
        for (String t : tbl_names) {
          lowered_tbl_names.add(normalizeIdentifier(t));
        }
      }

      StringBuilder filterBuilder = new StringBuilder();
      List<String> parameterVals = new ArrayList<>();
      appendPatternCondition(filterBuilder, "database.name", new String[] {db}, parameterVals);
      appendSimpleCondition(filterBuilder, "database.catalogName", new String[] {catName}, parameterVals);
      if(tbl_names != null){
        appendSimpleCondition(filterBuilder, "tableName", lowered_tbl_names.toArray(new String[0]), parameterVals);
      }
      if(tablePattern != null){
        appendPatternCondition(filterBuilder, "tableName", tablePattern, parameterVals);
      }
      query = pm.newQuery(MTable.class, filterBuilder.toString()) ;
      List<String> projectionFields = null;

      // If a projection specification has been set, validate it and translate it to JDO columns.
      if (projectionSpec != null) {
        //Validate the projection fields for multi-valued fields.
        projectionFields = TableFields.getMFieldNames(projectionSpec.getFieldList());
      }

      // If the JDO translation resulted in valid JDO columns names, use it to create a projection for the JDO query.
      if (projectionFields != null) {
        // fetch partially filled tables using result clause
        query.setResult(Joiner.on(',').join(projectionFields));
      }

      if (projectionFields == null) {
        mtables = (List<MTable>) query.executeWithArray(parameterVals.toArray(new String[parameterVals.size()]));
      } else {
        if (projectionFields.size() > 1) {
          // Execute the query to fetch the partial results.
          List<Object[]> results = (List<Object[]>) query.executeWithArray(parameterVals.toArray(new String[parameterVals.size()]));
          // Declare the tables array to return the list of tables
          mtables = new ArrayList<>(results.size());
          // Iterate through each row of the result and create the MTable object.
          for (Object[] row : results) {
            MTable mtable = new MTable();
            int i = 0;
            for (Object val : row) {
              MetaStoreServerUtils.setNestedProperty(mtable, projectionFields.get(i), val, true);
              i++;
            }
            mtables.add(mtable);
          }
        } else if (projectionFields.size() == 1) {
          // Execute the query to fetch the partial results.
          List<Object[]> results = (List<Object[]>) query.executeWithArray(parameterVals.toArray(new String[parameterVals.size()]));
          // Iterate through each row of the result and create the MTable object.
          mtables = new ArrayList<>(results.size());
          for (Object row : results) {
            MTable mtable = new MTable();
            MetaStoreServerUtils.setNestedProperty(mtable, projectionFields.get(0), row, true);
            mtables.add(mtable);
          }
        }
      }

      if (mtables == null || mtables.isEmpty()) {
        ensureGetDatabase(catName, db);
      } else {
        for (Iterator iter = mtables.iterator(); iter.hasNext(); ) {
          Table tbl = convertToTable((MTable) iter.next());
          // Retrieve creation metadata if needed
          if (TableType.MATERIALIZED_VIEW.toString().equals(tbl.getTableType())) {
            tbl.setCreationMetadata(
                    convertToCreationMetadata(
                            getCreationMetadata(tbl.getCatName(), tbl.getDbName(), tbl.getTableName())));
          }
          tables.add(tbl);
        }
      }
      committed = commitTransaction();
    } finally {
      rollbackAndCleanup(committed, query);
    }
    return tables;
  }
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