You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by sd...@apache.org on 2015/08/14 09:29:19 UTC

[45/50] [abbrv] incubator-sentry git commit: SENTRY-780: HDFS Plugin should not execute path callbacks for views (Ryan Pridgeon via Sravya Tirukkovalur)

SENTRY-780: HDFS Plugin should not execute path callbacks for views (Ryan Pridgeon via Sravya Tirukkovalur)


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/30c2eaf5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/30c2eaf5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/30c2eaf5

Branch: refs/heads/hive_plugin_v2
Commit: 30c2eaf5c6d6fecf87ba52a78395d8031a745f63
Parents: 6adcf78
Author: Sravya Tirukkovalur <sr...@cloudera.com>
Authored: Sun Aug 9 12:10:21 2015 -0700
Committer: Sravya Tirukkovalur <sr...@cloudera.com>
Committed: Sun Aug 9 12:10:21 2015 -0700

----------------------------------------------------------------------
 .../org/apache/sentry/hdfs/PathsUpdate.java     | 11 +++++-
 .../tests/e2e/hdfs/TestHDFSIntegration.java     | 36 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/30c2eaf5/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
----------------------------------------------------------------------
diff --git a/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java b/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
index 7cb20ef..79019f4 100644
--- a/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
+++ b/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
@@ -29,9 +29,12 @@ import org.apache.sentry.hdfs.service.thrift.TPathChanges;
 import org.apache.sentry.hdfs.service.thrift.TPathsUpdate;
 import org.apache.commons.httpclient.util.URIUtil;
 import org.apache.commons.httpclient.URIException;
+import org.apache.commons.lang.StringUtils;
 
 import com.google.common.collect.Lists;
 
+
+
 /**
  * A wrapper class over the TPathsUpdate thrift generated class. Please see
  * {@link Updateable.Update} for more information
@@ -92,8 +95,14 @@ public class PathsUpdate implements Updateable.Update {
    */
   public static List<String> parsePath(String path) {
     try {
-      URI uri = new URI(URIUtil.encodePath(path));
+
+      URI uri = null;
+      if (StringUtils.isNotEmpty(path)) {
+        uri = new URI(URIUtil.encodePath(path));
+      }
+
       Preconditions.checkNotNull(uri.getScheme());
+
       if(uri.getScheme().equalsIgnoreCase("hdfs")) {
         return Lists.newArrayList(uri.getPath().split("^/")[1]
             .split("/"));

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/30c2eaf5/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
index 6b584fd..e61dff0 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
@@ -1023,6 +1023,42 @@ public class TestHDFSIntegration {
     conn.close();
 
   }
+  //SENTRY-780
+  @Test
+  public void testViews() throws Throwable {
+    String dbName= "db1";
+
+    tmpHDFSDir = new Path("/tmp/external");
+    dbNames = new String[]{dbName};
+    roles = new String[]{"admin_role"};
+    admin = StaticUserGroup.ADMIN1;
+
+    Connection conn;
+    Statement stmt;
+
+    conn = hiveServer2.createConnection("hive", "hive");
+    stmt = conn.createStatement();
+
+    stmt.execute("create role admin_role");
+    stmt.execute("grant all on server server1 to role admin_role");
+    stmt.execute("grant role admin_role to group " + StaticUserGroup.ADMINGROUP);
+
+    conn = hiveServer2.createConnection(StaticUserGroup.ADMIN1, StaticUserGroup.ADMIN1);
+    stmt = conn.createStatement();
+    try {
+      stmt.execute("create database " + dbName);
+      stmt.execute("create table test(a string)");
+      stmt.execute("create view testView as select * from test");
+      stmt.execute("create or replace view testView as select * from test");
+      stmt.execute("drop view testView");
+    } catch(Exception s) {
+      throw s;
+    }
+
+    stmt.close();
+    conn.close();
+  }
+
 
   private void verifyQuery(Statement stmt, String table, int n) throws Throwable {
     verifyQuery(stmt, table, n, NUM_RETRIES);