ArrayList<String> partVals2 = Lists.newArrayList("part2");
ArrayList<String> partVals3 = Lists.newArrayList("part3");
ArrayList<String> partVals4 = Lists.newArrayList("part4");
// user with ALL on DB should be able to add partition
HiveMetaStoreClient client = context.getMetaStoreClient(USER1_1);
Table tbl1 = createMetastoreTableWithPartition(client, dbName, tabName1,
Lists.newArrayList(new FieldSchema("col1", "int", "")),
Lists.newArrayList(new FieldSchema("part_col1", "string", "")));
assertEquals(1, client.getTables(dbName, tabName1).size());
addPartition(client, dbName, tabName1, partVals1, tbl1);
addPartition(client, dbName, tabName1, partVals2, tbl1);
client.close();
// user with ALL on Table should be able to add partition
client = context.getMetaStoreClient(USER2_1);
tbl1 = client.getTable(dbName, tabName1);
addPartition(client, dbName, tabName1, partVals3, tbl1);
client.close();
// user without ALL on DB or Table should NOT be able to add partition
client = context.getMetaStoreClient(USER3_1);
tbl1 = client.getTable(dbName, tabName1);
try {
addPartition(client, dbName, tabName1, partVals4, tbl1);
fail("Add partition should have failed for non-admin user");
} catch (MetaException e) {
Context.verifyMetastoreAuthException(e);
}
client.close();
// user with ALL on DB should be able to drop partition
client = context.getMetaStoreClient(USER1_1);
tbl1 = client.getTable(dbName, tabName1);
client.dropPartition(dbName, tabName1, partVals1, true);
client.close();
// user with ALL on Table should be able to drop partition
client = context.getMetaStoreClient(USER2_1);
tbl1 = client.getTable(dbName, tabName1);
client.dropPartition(dbName, tabName1, partVals2, true);
client.close();
// user without ALL on DB or Table should NOT be able to drop partition
client = context.getMetaStoreClient(USER3_1);
try {
addPartition(client, dbName, tabName1, partVals3, tbl1);