[ 
https://issues.apache.org/jira/browse/HIVE-22512?focusedWorklogId=347427&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-347427
 ]

ASF GitHub Bot logged work on HIVE-22512:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Nov/19 14:09
            Start Date: 21/Nov/19 14:09
    Worklog Time Spent: 10m 
      Work Description: maheshk114 commented on pull request #847: HIVE-22512 : 
Use direct SQL to fetch column privileges in refreshPrivileges.
URL: https://github.com/apache/hive/pull/847#discussion_r349046033
 
 

 ##########
 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\", " +
 
 Review comment:
   is it tested for all db (mysql, prostgres, oracle, mssql ) ?
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 347427)
    Time Spent: 40m  (was: 0.5h)

> Use direct SQL to fetch column privileges in refreshPrivileges
> --------------------------------------------------------------
>
>                 Key: HIVE-22512
>                 URL: https://issues.apache.org/jira/browse/HIVE-22512
>             Project: Hive
>          Issue Type: Improvement
>          Components: Metastore
>    Affects Versions: 4.0.0
>            Reporter: Ashutosh Bapat
>            Assignee: Ashutosh Bapat
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-22512.01.patch, HIVE-22512.02.patch
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> refreshPrivileges() callsĀ listTableAllColumnGrants() to fetch the column 
> level privileges. The later function retrieves the individual column objects 
> by firing one query per column privilege object, thus causing the backend db 
> to be swamped by these queries when PrivilegeSynchronizer is run. 
> PrivilegeSynchronizer synchronizes privileges of all the databases, tables 
> and columns and thus the backend db can get swamped really bad when there are 
> thousands of tables with hundreds of columns.
> The output of listTableAllColumnGrants() is not used completely so all the 
> columns the PM has tried to retrieves anyway goes waste.
> Fix this by using direct SQL to fetch column privileges.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to