You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by pr...@apache.org on 2015/04/22 18:11:10 UTC
incubator-sentry git commit: SENTRY-703: Calls to add_partition fail
when passed a Partition object with a null location (Prasad Mujumdar,
reviewed by Dapeng Sun)
Repository: incubator-sentry
Updated Branches:
refs/heads/master 7ae7fc375 -> a3adbb391
SENTRY-703: Calls to add_partition fail when passed a Partition object with a null location (Prasad Mujumdar, reviewed by Dapeng Sun)
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/a3adbb39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/a3adbb39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/a3adbb39
Branch: refs/heads/master
Commit: a3adbb39151aa67ed0117897242743ecc6a97cf3
Parents: 7ae7fc3
Author: Prasad Mujumdar <pr...@cloudera.com>
Authored: Wed Apr 22 09:11:09 2015 -0700
Committer: Prasad Mujumdar <pr...@cloudera.com>
Committed: Wed Apr 22 09:11:09 2015 -0700
----------------------------------------------------------------------
.../metastore/MetastoreAuthzBinding.java | 5 ++-
.../e2e/metastore/TestMetastoreEndToEnd.java | 36 ++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a3adbb39/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/MetastoreAuthzBinding.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/MetastoreAuthzBinding.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/MetastoreAuthzBinding.java
index f16341d..5375f6a 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/MetastoreAuthzBinding.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/MetastoreAuthzBinding.java
@@ -311,8 +311,11 @@ public class MetastoreAuthzBinding extends MetaStorePreEventListener {
// check if we need to validate URI permissions when storage location is
// non-default, ie something not under the parent table
+ String partitionLocation = null;
if (mapiPart.isSetSd()) {
- String partitionLocation = mapiPart.getSd().getLocation();
+ partitionLocation = mapiPart.getSd().getLocation();
+ }
+ if (!StringUtils.isEmpty(partitionLocation)) {
String tableLocation = context
.getHandler()
.get_table(mapiPart.getDbName(),
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a3adbb39/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java
index 09433fd..c13222f 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
@@ -543,6 +544,41 @@ public class TestMetastoreEndToEnd extends
+ dbName + "." + tabName1, USER1_1, dynamicInsertProperties);
}
+ @Test
+ public void testAddPartion() throws Exception {
+ String partVal1 = "part1", partVal2 = "part2", partVal3 = "part5";
+ String newPath1 = "fooTab1";
+ String tabDir1 = hiveServer.getProperty(HiveServerFactory.WAREHOUSE_DIR)
+ + File.separator + newPath1;
+
+ policyFile.addRolesToGroup(USERGROUP1, uri_role).addPermissionsToRole(
+ uri_role, "server=server1->URI=" + tabDir1);
+ writePolicyFile(policyFile);
+
+ execHiveSQL("DROP TABLE IF EXISTS " + dbName + "." + tabName1, USER1_1);
+ execHiveSQL("CREATE TABLE " + dbName + "." + tabName1
+ + " (id int) PARTITIONED BY (part_col string)", USER1_1);
+
+ execHiveSQL("ALTER TABLE " + dbName + "." + tabName1
+ + " ADD PARTITION (part_col ='" + partVal1 + "')", USER1_1);
+ verifyPartitionExists(dbName, tabName1, partVal1);
+
+ execHiveSQL("ALTER TABLE " + dbName + "." + tabName1
+ + " ADD PARTITION (part_col ='" + partVal2 + "') location '"
+ + tabDir1 + "'", USER1_1);
+ verifyPartitionExists(dbName, tabName1, partVal2);
+
+ try {
+ execHiveSQL("ALTER TABLE " + dbName + "." + tabName1
+ + " ADD PARTITION (part_col ='" + partVal2 + "') location '"
+ + tabDir1 + "'", USER2_1);
+ fail("alter table should have failed due to missing URI privilege");
+ } catch (IOException e) {
+ // Expected error
+ }
+
+ }
+
private void verifyPartitionExists(String dbName, String tabName,
String partVal) throws Exception {
HiveMetaStoreClient client = context.getMetaStoreClient(ADMIN1);