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

Change-Id: Ife376d2ccb31dac906e56e155ae5968d955d1f41
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/22690
Tested-by: Jenkins User
Reviewed-by: Alexander Kolbasov <[email protected]>


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

Branch: refs/for/cdh5-1.5.1_ha
Commit: f0faf2f3da02e044f0702ba77c6e7c34e4d1b52b
Parents: 8841a02
Author: Alexander Kolbasov <[email protected]>
Authored: Mon May 15 20:39:08 2017 -0700
Committer: Alexander Kolbasov <[email protected]>
Committed: Tue May 16 12:05:35 2017 -0700

----------------------------------------------------------------------
 .../sentry/binding/hive/HiveAuthzBindingHook.java     | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/f0faf2f3/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 83b6684..2a842c5 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
@@ -290,9 +290,17 @@ public class HiveAuthzBindingHook extends 
AbstractSemanticAnalyzerHook {
         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;
       default:
         currDB = getCanonicalDb();

Reply via email to