ayushtkn commented on code in PR #6744:
URL: https://github.com/apache/hive/pull/6744#discussion_r4621500842


##########
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/HiveMetaStoreAuthorizer.java:
##########
@@ -140,10 +140,9 @@ public final List<String> filterDatabases(String catName, 
List<String> list) thr
   @Override
   public final Database filterDatabase(Database database) throws 
MetaException, NoSuchObjectException {
     if (database != null) {
-      String dbName = database.getName();
-      List<String> databases = filterDatabases(database.getCatalogName(), 
Collections.singletonList(dbName));
-      if (databases.isEmpty()) {
-        throw new NoSuchObjectException(String.format("Database %s does not 
exist", dbName));
+      List<Database> filteredDatabases = 
filterDatabaseObjects(Collections.singletonList(database));

Review Comment:
   Thanx @tanishq-chugh for the fix, overall looks good to me.
   
   I think after this change we are loosing the client config, which the 
private `filterDatabaseObjects` does call but the not public one 🤷  Can u 
double check once.
   
   Maybe create a method like this
   ```
   private HiveAuthzContext applyClientConfig(HiveAuthzContext 
hiveAuthzContext) {
     Map<String, Object> clientConfig = cConfig.get();
     if (clientConfig == null) {
       return hiveAuthzContext;
     }
     HiveAuthzContext.Builder builder = new HiveAuthzContext.Builder();
     builder.setClientConfig(clientConfig);
     if (hiveAuthzContext != null) {
       builder.setCommandString(hiveAuthzContext.getCommandString());
       builder.setUserIpAddress(hiveAuthzContext.getIpAddress());
       builder.setForwardedAddresses(hiveAuthzContext.getForwardedAddresses());
     }
     return builder.build();
   }
   ```
   
   and then in both call
   ```
   HiveAuthzContext hiveAuthzContext =
       applyClientConfig(hiveMetaStoreAuthzInfo.getHiveAuthzContext());
   ```
   
   `filterTableNames` and `filterTables` also have the same problem, that you 
can deal as another PR as followup, upto u



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to