Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ private static List<HivePrivilegeObject> getHivePrivObjects(List<? extends Entit
continue;
}

// skip partition for SELECT query
if (privObject.getTyp() == Type.PARTITION && privObject instanceof ReadEntity) {
LOG.debug("skip partition: {}", privObject);
continue;
}

if (privObject.getTyp() == Type.FUNCTION && !HiveConf.getBoolVar(SessionState.get().getConf(),
HiveConf.ConfVars.HIVE_AUTHORIZATION_FUNCTIONS_IN_VIEW) && hiveOpType == HiveOperationType.QUERY) {
String[] qualifiedFunctionName = new String[]{privObject.getDatabase() != null ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,27 @@ public void testSingleInstanceOfHPOForPartitionedTable() throws Exception {
Assert.assertEquals(1, hpoList.size());
}


/**
* Test to check, if only single instance of Hive Privilege object is created,
* during select from a partitioned table.
*/
@Test
public void testSelectSingleInstanceOfHPOForPartitionedTable() throws Exception {
runCmd("CREATE EXTERNAL TABLE Part2 (eid int, name int) PARTITIONED BY (position int, dept int, sal int)");

runCmd("insert overwrite table part2 partition(position=2,DEPT,SAL) select 2,2,2,2");
runCmd("insert overwrite table part2 partition(position=3,DEPT,SAL) select 3,3,3,3");
reset(mockedAuthorizer);
runCmd("SELECT * FROM part2");
Pair<List<HivePrivilegeObject>, List<HivePrivilegeObject>> io = getHivePrivilegeObjectInputs();
List<HivePrivilegeObject> hpoList = io.getKey();
Assert.assertEquals(1, hpoList.size());
Assert.assertEquals(HivePrivilegeObject.HivePrivilegeObjectType.TABLE_OR_VIEW, hpoList.get(0).getType());

runCmd("DROP table part2");
}

/**
* @return pair with left value as inputs and right value as outputs,
* passed in current call to authorizer.checkPrivileges
Expand Down
1 change: 1 addition & 0 deletions ql/src/test/resources/META-INF/services/java.sql.Driver
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.calcite.jdbc.Driver
Loading