sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sp...@apache.org
Subject sentry git commit: SENTRY-2066: DB name is not set for AlterTable (Na Li, reviewed by Sergio Pena, Arjun Mishra)
Date Wed, 22 Nov 2017 00:36:59 GMT
Repository: sentry
Updated Branches:
  refs/heads/master 3dc8d2f90 -> b85b323fb


SENTRY-2066: DB name is not set for AlterTable (Na Li, reviewed by Sergio Pena, Arjun Mishra)


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

Branch: refs/heads/master
Commit: b85b323fbf17f0d0a1fffbc3be7ef95fe79583fa
Parents: 3dc8d2f
Author: Sergio Pena <sergio.pena@cloudera.com>
Authored: Tue Nov 21 18:15:48 2017 -0600
Committer: Sergio Pena <sergio.pena@cloudera.com>
Committed: Tue Nov 21 18:15:48 2017 -0600

----------------------------------------------------------------------
 .../sentry/binding/hive/HiveAuthzBindingHook.java    |  4 ++--
 .../dbprovider/TestDbSentryOnFailureHookLoading.java | 15 ++++-----------
 2 files changed, 6 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/b85b323f/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 e4620ea..09bd9b5 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
@@ -262,14 +262,13 @@ public class HiveAuthzBindingHook extends HiveAuthzBindingHookBase {
         }
         break;
     case HiveParser.TOK_ALTERTABLE:
-
+      currDB = getCanonicalDb();
       for (Node childNode : ast.getChildren()) {
         ASTNode childASTNode = (ASTNode) childNode;
         if ("TOK_ALTERTABLE_SERIALIZER".equals(childASTNode.getText())) {
           ASTNode serdeNode = (ASTNode)childASTNode.getChild(0);
           String serdeClassName = BaseSemanticAnalyzer.unescapeSQLString(serdeNode.getText());
           setSerdeURI(serdeClassName);
-          currDB = getCanonicalDb();
         }
         if ("TOK_ALTERTABLE_RENAME".equals(childASTNode.getText())) {
           currDB = extractDatabase((ASTNode)ast.getChild(0));
@@ -277,6 +276,7 @@ public class HiveAuthzBindingHook extends HiveAuthzBindingHookBase {
           currOutDB = extractDatabase(newTableNode);
         }
       }
+
       break;
     default:
         currDB = getCanonicalDb();

http://git-wip-us.apache.org/repos/asf/sentry/blob/b85b323f/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java
b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java
index aa99595..d0e0dae 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java
@@ -36,13 +36,9 @@ import org.junit.After;
 import org.junit.Assume;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class TestDbSentryOnFailureHookLoading extends AbstractTestWithDbProvider {
 
-  private static final Logger LOGGER = LoggerFactory.getLogger(TestDbSentryOnFailureHookLoading.class);
-
   @BeforeClass
   public static void setup() throws Exception {
     properties = new HashMap<String, String>();
@@ -264,16 +260,13 @@ public class TestDbSentryOnFailureHookLoading extends AbstractTestWithDbProvider
     }
     if(tableName != null) {
       Assert.assertNotNull("Table object is null for op: " + expectedOp, DummySentryOnFailureHook.table);
-      Assert.assertTrue(tableName.equalsIgnoreCase(DummySentryOnFailureHook.table.getName()));
+      Assert.assertNotNull("Table name is null for op: " + expectedOp, DummySentryOnFailureHook.table.getName());
+      Assert.assertEquals(tableName.toLowerCase(), DummySentryOnFailureHook.table.getName().toLowerCase());
     }
     if(dbName != null) {
       Assert.assertNotNull("Database object is null for op: " + expectedOp, DummySentryOnFailureHook.db);
-
-      String failureHookDbName = DummySentryOnFailureHook.db.getName();
-      LOGGER.debug("dbName: {}; DummySentryOnFailureHook.db.getName(): {}", dbName, failureHookDbName);
-      if(!failureHookDbName.equalsIgnoreCase("*")) {
-        Assert.assertTrue(dbName.equalsIgnoreCase(failureHookDbName));
-      }
+      Assert.assertNotNull("Database name is null for op: " + expectedOp, DummySentryOnFailureHook.db.getName());
+      Assert.assertEquals(dbName.toLowerCase(), DummySentryOnFailureHook.db.getName().toLowerCase());
     }
   }
 }


Mime
View raw message