sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject [18/18] sentry git commit: SENTRY-1320: truncate table db_name.table_name fails (Vihang Karajgaonkar, Reviewed by: Sravya Tirukkovalur)
Date Mon, 13 Jun 2016 02:52:22 GMT
SENTRY-1320: truncate table db_name.table_name fails (Vihang Karajgaonkar, Reviewed by: Sravya
Tirukkovalur)

Change-Id: I32be718e9a25ac30aaedc0f3773853dc9d1cc27e


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

Branch: refs/heads/SENTRY-1205
Commit: 38098b46167204761a24ca39f1e8bca2038156cc
Parents: 170eb22
Author: Sravya Tirukkovalur <sravya@apache.org>
Authored: Fri Jun 10 10:43:14 2016 -0700
Committer: Sravya Tirukkovalur <sravya@apache.org>
Committed: Fri Jun 10 10:43:14 2016 -0700

----------------------------------------------------------------------
 .../sentry/binding/hive/HiveAuthzBindingHook.java     |  2 +-
 .../e2e/hive/TestPrivilegesAtTableScopePart2.java     | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/38098b46/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
index a13ab79..7242fde 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
@@ -239,7 +239,7 @@ public class HiveAuthzBindingHook extends HiveAuthzBindingHookBase {
         Preconditions.checkArgument(ast.getChildCount() == 1);
         // childcount is 1 for table without partition, 2 for table with partitions
         Preconditions.checkArgument(ast.getChild(0).getChildCount() >= 1);
-        Preconditions.checkArgument(ast.getChild(0).getChild(0).getChildCount() == 1);
+        Preconditions.checkArgument(ast.getChild(0).getChild(0).getChildCount() >= 1);
         currOutDB = extractDatabase((ASTNode) ast.getChild(0));
         currOutTab = extractTable((ASTNode) ast.getChild(0).getChild(0).getChild(0));
         break;

http://git-wip-us.apache.org/repos/asf/sentry/blob/38098b46/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScopePart2.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScopePart2.java
b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScopePart2.java
index 3b5f6a6..0cd272e 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScopePart2.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScopePart2.java
@@ -64,6 +64,9 @@ public class TestPrivilegesAtTableScopePart2 extends AbstractTestWithStaticConfi
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
 
+    statement.execute("DROP DATABASE IF EXISTS DB_2 CASCADE");
+    statement.execute("CREATE DATABASE DB_2");
+
     statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
     statement.execute("CREATE DATABASE DB_1");
     statement.execute("USE DB_1");
@@ -121,6 +124,12 @@ public class TestPrivilegesAtTableScopePart2 extends AbstractTestWithStaticConfi
     // verify admin can execute truncate table
     statement.execute("TRUNCATE TABLE " + TBL1);
     assertFalse(hasData(statement, TBL1));
+    // verify admin can execute truncate table from different db
+    statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath()
+    + "' INTO TABLE " + TBL1);
+    statement.execute("USE " + DB2);
+    statement.execute("TRUNCATE TABLE " + DB1 + "." + TBL1);
+    assertFalse(hasData(statement, DB1 + "." + TBL1));
 
     statement.close();
     connection.close();
@@ -163,6 +172,11 @@ public class TestPrivilegesAtTableScopePart2 extends AbstractTestWithStaticConfi
     // verify admin can execute truncate empty partitioned table
     statement.execute("TRUNCATE TABLE " + TBL1);
     assertFalse(hasData(statement, TBL1));
+    // verify admin can execute truncate empty partitioned table from outside db
+    statement.execute("USE " + DB2);
+    statement.execute("TRUNCATE TABLE " + DB1 + "." + TBL1);
+    assertFalse(hasData(statement, DB1 + "."+ TBL1));
+
     statement.close();
     connection.close();
 


Mime
View raw message