public List<HiveObjectPrivilege> getTableAllColumnGrants(String catName, String dbName,
                                                           String tableName, String authorizer) throws MetaException {
    // These constants should match the SELECT clause of the query.
    final int authorizerIndex = 0;
    final int columnNameIndex = 1;
    final int createTimeIndex = 2;
    final int grantOptionIndex = 3;
    final int grantorIndex = 4;
    final int grantorTypeIndex = 5;
    final int principalNameIndex = 6;
    final int principalTypeIndex = 7;
    final int privilegeIndex = 8;

    // Retrieve the privileges from the object store. Just grab only the required fields.
    String queryText = "select " +
            TBL_COL_PRIVS + ".\"AUTHORIZER\", " +
            TBL_COL_PRIVS + ".\"COLUMN_NAME\", " +
            TBL_COL_PRIVS + ".\"CREATE_TIME\", " +
            TBL_COL_PRIVS + ".\"GRANT_OPTION\", " +
            TBL_COL_PRIVS + ".\"GRANTOR\", " +
            TBL_COL_PRIVS + ".\"GRANTOR_TYPE\", " +
            TBL_COL_PRIVS + ".\"PRINCIPAL_NAME\", " +
            TBL_COL_PRIVS + ".\"PRINCIPAL_TYPE\", " +
            TBL_COL_PRIVS + ".\"TBL_COL_PRIV\" " +
            "FROM " + TBL_COL_PRIVS + " JOIN " + TBLS +
            " ON " + TBL_COL_PRIVS + ".\"TBL_ID\" = " + TBLS + ".\"TBL_ID\"" +
            " JOIN " + DBS + " ON " + TBLS + ".\"DB_ID\" = " + DBS + ".\"DB_ID\" " +
            " WHERE " + TBLS + ".\"TBL_NAME\" = ?" +
            " AND " + DBS + ".\"NAME\" = ?" +
            " AND " + DBS + ".\"CTLG_NAME\" = ?";

    // Build the parameters, they should match the WHERE clause of the query.
    int numParams = authorizer != null ? 4 : 3;
    Object[] params = new Object[numParams];
    params[0] = tableName;
    params[1] = dbName;
    params[2] = catName;
    if (authorizer != null) {
      queryText = queryText + " AND " + TBL_COL_PRIVS + ".\"AUTHORIZER\" = ?";
      params[3] = authorizer;
    }

    // Collect the results into a list that the caller can consume.
    List<HiveObjectPrivilege> result = new ArrayList<>();
    final boolean doTrace = LOG.isDebugEnabled();
    long start = doTrace ? System.nanoTime() : 0;
    try (QueryWrapper query = new QueryWrapper(pm.newQuery("javax.jdo.query.SQL", queryText))) {
      List<Object[]> queryResult = MetastoreDirectSqlUtils.ensureList(
              executeWithArray(query.getInnerQuery(), params, queryText));
      long end = doTrace ? System.nanoTime() : 0;
      MetastoreDirectSqlUtils.timingTrace(doTrace, queryText, start, end);

      // If there is some result convert it into HivePrivilege bag and return.
      for (Object[] privLine : queryResult) {
        String privAuthorizer = MetastoreDirectSqlUtils.extractSqlString(privLine[authorizerIndex]);
        String principalName = MetastoreDirectSqlUtils.extractSqlString(privLine[principalNameIndex]);
        PrincipalType ptype = PrincipalType.valueOf(
                MetastoreDirectSqlUtils.extractSqlString(privLine[principalTypeIndex]));
        String columnName = MetastoreDirectSqlUtils.extractSqlString(privLine[columnNameIndex]);
        String privilege = MetastoreDirectSqlUtils.extractSqlString(privLine[privilegeIndex]);
        int createTime = MetastoreDirectSqlUtils.extractSqlInt(privLine[createTimeIndex]);
        String grantor = MetastoreDirectSqlUtils.extractSqlString(privLine[grantorIndex]);
        PrincipalType grantorType =
                PrincipalType.valueOf(
                        MetastoreDirectSqlUtils.extractSqlString(privLine[grantorTypeIndex]));
        boolean grantOption = MetastoreDirectSqlUtils.extractSqlBoolean(privLine[grantOptionIndex]);

        HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.COLUMN, dbName, tableName, null,
                columnName);
        objectRef.setCatName(catName);
        PrivilegeGrantInfo grantInfo = new PrivilegeGrantInfo(privilege, createTime, grantor,
                grantorType, grantOption);

        result.add(new HiveObjectPrivilege(objectRef, principalName, ptype, grantInfo,
                privAuthorizer));
      }
    }

    return result;
  }
Retrieve the column statistics for the specified columns of the table. NULL
is returned if the columns are not provided.
@param catName     the catalog name of the table
@param dbName      the database name of the table
@param tableName   the table name
@param colNames    the list of the column names
@param engine      engine making the request
@return            the column statistics for the specified columns
@throws MetaException
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java