sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject sentry git commit: SENTRY-1646 Unable to truncate table <database>.<tablename>; from "default" databases (Yongzhi Chen, reviewed by: Hao Hao and Sergio Pena)
Date Tue, 16 May 2017 00:56:54 GMT
Repository: sentry
Updated Branches:
  refs/heads/master 3834e3b15 -> 306ccb390


SENTRY-1646 Unable to truncate table <database>.<tablename>; from "default" databases
(Yongzhi Chen, reviewed by: Hao Hao and Sergio Pena)


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

Branch: refs/heads/master
Commit: 306ccb390b7579f015caadc0e604648e59b3a32b
Parents: 3834e3b
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Mon May 15 17:54:42 2017 -0700
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Mon May 15 17:54:42 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/sentry/blob/306ccb39/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 d269d5f..34683f4 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
@@ -249,9 +249,17 @@ 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);
-        currOutDB = extractDatabase((ASTNode) ast.getChild(0));
-        currOutTab = extractTable((ASTNode) ast.getChild(0).getChild(0).getChild(0));
+        ASTNode tableTok = (ASTNode) ast.getChild(0).getChild(0);
+        Preconditions.checkArgument(tableTok.getChildCount() >= 1);
+        if (tableTok.getChildCount() == 1) {
+          // If tableTok chilcount is 1, tableTok does not has database information, use
current working DB
+          currOutDB = extractDatabase((ASTNode) ast.getChild(0));
+          currOutTab = extractTable((ASTNode) tableTok.getChild(0));
+        } else {
+          // If tableTok has fully-qualified name(childcount is 2),
+          // get the db and table information from tableTok.
+          extractDbTableNameFromTOKTABLE(tableTok);
+        }
         break;
     case HiveParser.TOK_ALTERTABLE:
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/306ccb39/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 8eb0bd6..4c76eee 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
@@ -315,6 +315,10 @@ public class TestPrivilegesAtTableScopePart2 extends AbstractTestWithStaticConfi
       }
       statement.execute("TRUNCATE TABLE " + TBL2);
       assertFalse(hasData(statement, TBL2));
+
+      statement.execute("USE " + DEFAULT);
+      statement.execute("TRUNCATE TABLE " + DB1 + "." + TBL2);
+      assertFalse(hasData(statement,  DB1 + "." + TBL2));
       statement.close();
       connection.close();
 


Mime
View raw message