You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by sr...@apache.org on 2016/06/10 17:43:33 UTC
sentry git commit: SENTRY-1320: truncate table db_name.table_name
fails (Vihang Karajgaonkar, Reviewed by: Sravya Tirukkovalur)
Repository: sentry
Updated Branches:
refs/heads/master 170eb22f6 -> 38098b461
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/master
Commit: 38098b46167204761a24ca39f1e8bca2038156cc
Parents: 170eb22
Author: Sravya Tirukkovalur <sr...@apache.org>
Authored: Fri Jun 10 10:43:14 2016 -0700
Committer: Sravya Tirukkovalur <sr...@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();