Skip to content

Commit

Permalink
RANGER-5097: Fix setOwnerUser function to ensure the Hive default {ow…
Browse files Browse the repository at this point in the history
…ner} policy works correctly
  • Loading branch information
maheshbandal15 committed Jan 29, 2025
1 parent cbf4152 commit 94072cf
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,16 @@ public RangerHiveAuthorizer(HiveMetastoreClientFactory metastoreClientFactory, H
static void setOwnerUser(RangerHiveResource resource, HivePrivilegeObject hiveObj, IMetaStoreClient metaStoreClient, Map<String, String> objOwners) {
if (hiveObj != null) {
String objName = null;
String owner = null;
String owner = hiveObj.getOwnerName();

// resource.setOwnerUser(hiveObj.getOwnerName());
switch (hiveObj.getType()) {
case DATABASE:
try {
objName = hiveObj.getDbname();
owner = objOwners != null ? objOwners.get(objName) : null;
if (StringUtils.isBlank(owner) && objOwners != null) {
owner = objOwners.get(objName);
}

if (StringUtils.isBlank(owner)) {
Database database = metaStoreClient != null ? metaStoreClient.getDatabase(hiveObj.getDbname()) : null;
Expand All @@ -199,7 +201,9 @@ static void setOwnerUser(RangerHiveResource resource, HivePrivilegeObject hiveOb
case COLUMN:
try {
objName = hiveObj.getDbname() + "." + hiveObj.getObjectName();
owner = objOwners != null ? objOwners.get(objName) : null;
if (StringUtils.isBlank(owner) && objOwners != null) {
owner = objOwners.get(objName);
}

if (StringUtils.isBlank(owner)) {
Table table = metaStoreClient != null ? metaStoreClient.getTable(hiveObj.getDbname(), hiveObj.getObjectName()) : null;
Expand Down

0 comments on commit 94072cf

Please sign in to comment.