Repository: incubator-atlas
Updated Branches:
  refs/heads/master f7146ede4 -> daf812aad


ATLAS-594 alter table rename doesnt work across databases ( sumasai via 
shwethags)


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

Branch: refs/heads/master
Commit: daf812aadf0179682ff0a1947cf93811e10b9460
Parents: f7146ed
Author: Suma Shivaprasad <[email protected]>
Authored: Thu Apr 14 11:16:02 2016 -0700
Committer: Suma Shivaprasad <[email protected]>
Committed: Thu Apr 14 11:16:02 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/atlas/hive/hook/HiveHook.java    |  8 ++++----
 .../test/java/org/apache/atlas/hive/hook/HiveHookIT.java  | 10 +++++++---
 release-log.txt                                           |  1 +
 3 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/daf812aa/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
----------------------------------------------------------------------
diff --git 
a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java 
b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
index a0f1d40..b9f00fd 100755
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
@@ -406,10 +406,9 @@ public class HiveHook extends AtlasHook implements 
ExecuteWithHookContext {
         for (WriteEntity writeEntity : event.getOutputs()) {
             if (writeEntity.getType() == Entity.Type.TABLE) {
                 Table newTable = writeEntity.getTable();
-                if (newTable.getDbName().equals(oldTable.getDbName()) && 
!newTable.getTableName()
-                    .equals(oldTable.getTableName())) {
-
-                    //Create/update old table entity - create new entity and 
replace id
+                //Hive sends with both old and new table names in the outputs 
which is weird. So skipping that with the below check
+                if (!newTable.getDbName().equals(oldTable.getDbName()) || 
!newTable.getTableName().equals(oldTable.getTableName())) {
+                    //Create/update old table entity - create new entity with 
oldQFNme and tableName
                     Referenceable tableEntity = 
createOrUpdateEntities(dgiBridge, event.getUser(), writeEntity);
                     String oldQualifiedName = 
dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),
                         oldTable.getDbName(), oldTable.getTableName());
@@ -419,6 +418,7 @@ public class HiveHook extends AtlasHook implements 
ExecuteWithHookContext {
                     String newQualifiedName = 
dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),
                         newTable.getDbName(), newTable.getTableName());
 
+                    //Replace entity with new name
                     Referenceable newEntity = new 
Referenceable(HiveDataTypes.HIVE_TABLE.getName());
                     newEntity.set(HiveDataModelGenerator.NAME, 
newQualifiedName);
                     newEntity.set(HiveDataModelGenerator.TABLE_NAME, 
newTable.getTableName().toLowerCase());

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/daf812aa/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
----------------------------------------------------------------------
diff --git 
a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java 
b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
index dbba926..683f43c 100755
--- 
a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
+++ 
b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
@@ -557,11 +557,15 @@ public class HiveHookIT {
     @Test
     public void testAlterTableRename() throws Exception {
         String tableName = createTable();
-        String newName = tableName();
-        String query = "alter table " + tableName + " rename to " + newName;
+        final String newDBName = createDatabase();
+        assertTableIsRegistered(DEFAULT_DB, tableName);
+        assertDatabaseIsRegistered(newDBName);
+
+        String newTableName = tableName();
+        String query = String.format("alter table %s rename to %s", DEFAULT_DB 
+ "." + tableName, newDBName + "." + newTableName);
         runCommand(query);
 
-        assertTableIsRegistered(DEFAULT_DB, newName);
+        assertTableIsRegistered(newDBName, newTableName);
         assertTableIsNotRegistered(DEFAULT_DB, tableName);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/daf812aa/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index b5476f8..64446f4 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -15,6 +15,7 @@ ATLAS-409 Atlas will not import avro tables with schema read 
from a file (dosset
 ATLAS-379 Create sqoop and falcon metadata addons 
(venkatnrangan,bvellanki,sowmyaramesh via shwethags)
 
 ALL CHANGES:
+ATLAS-594 alter table rename doesnt work across databases (sumasai via 
shwethags)
 ATLAS-586 While updating the multiple attributes, Atlas returns the response 
with escape characters (dkantor via shwethags)
 ATLAS-582 Move Atlas UI to use backboneJS (kevalbhatt18 via shwethags)
 ATLAS-540 API to retrieve entity version events (shwethags)

Reply via email to