This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 2450227  ATLAS-3590: fix HiveHook to avoid incorrect 
alter-table-property notifications
2450227 is described below

commit 2450227dcd1c6c4827bb6e8b80ab86f71babc3f0
Author: mayanknj <mayank.j...@freestoneinfotech.com>
AuthorDate: Wed Nov 27 18:19:44 2019 +0530

    ATLAS-3590: fix HiveHook to avoid incorrect alter-table-property 
notifications
    
    Signed-off-by: Madhan Neethiraj <mad...@apache.org>
    (cherry picked from commit 9f5b7861e6bf4975b84cd9db0f3397d128cb3157)
---
 .../apache/atlas/hive/hook/HiveMetastoreHookImpl.java  | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveMetastoreHookImpl.java
 
b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveMetastoreHookImpl.java
index 251fddd..1585b43 100644
--- 
a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveMetastoreHookImpl.java
+++ 
b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveMetastoreHookImpl.java
@@ -94,7 +94,7 @@ public class HiveMetastoreHookImpl extends 
MetaStoreEventListener {
             context.setOperation(ALTERTABLE_RENAME);
         } else if (isColumnRename(oldTable, newTable, context)) {
             context.setOperation(ALTERTABLE_RENAMECOL);
-        } else {
+        } else if(isAlterTableProperty(tableEvent)){
             context.setOperation(ALTERTABLE_PROPERTIES); // map other alter 
table operations to ALTERTABLE_PROPERTIES
         }
 
@@ -190,4 +190,20 @@ public class HiveMetastoreHookImpl extends 
MetaStoreEventListener {
 
         return isColumnRename;
     }
+
+    private boolean isAlterTableProperty(AlterTableEvent tableEvent) {
+        final boolean ret;
+        String        oldTableModifiedTime = 
tableEvent.getOldTable().getParameters().get("last_modified_time");
+        String        newTableModifiedTime = 
tableEvent.getNewTable().getParameters().get("last_modified_time");
+
+
+        if (oldTableModifiedTime == null) {
+            ret = newTableModifiedTime != null;
+        } else {
+            ret = !oldTableModifiedTime.equals(newTableModifiedTime);
+        }
+
+        return ret;
+
+    }
 }
\ No newline at end of file

Reply via email to