You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2019/11/22 04:44:10 UTC

[GitHub] [hive] ashutosh-bapat commented on a change in pull request #847: HIVE-22512 : Use direct SQL to fetch column privileges in refreshPrivileges.

ashutosh-bapat commented on a change in pull request #847: HIVE-22512 : Use direct SQL to fetch column privileges in refreshPrivileges.
URL: https://github.com/apache/hive/pull/847#discussion_r349431537
 
 

 ##########
 File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
 ##########
 @@ -1280,6 +1284,94 @@ public ColumnStatistics getTableStats(final String catName, final String dbName,
     return result;
   }
 
+  public List<HiveObjectPrivilege> getTableAllColumnGrants(String catName, String dbName,
+                                                           String tableName, String authorizer) throws MetaException {
+    Query query = null;
+
+    // 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\", " +
 
 Review comment:
   JDO uses LEFT OUTER JOIN In the corresponding query fired through JDO. So, I used just that. But I think LEFT OUTER JOIN doesn't have any effect here because of the WHERE clause at the end. The WHERE clauses are on the RIGHT side columns. These clauses will evaluate to false when the RIGHT side columns will be NULL, effectively turning this OUTER join into an INNER join.
   
   It's better to leave LEFT JOIN as is in case someone wants to compare this query with JDO query. But if you think we should use INNER JOIN here, I will use INNER JOIN.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org