You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2018/04/05 22:28:42 UTC

atlas git commit: ATLAS-2530 trim query string before using it as name attribute for Hive process and column lineage

Repository: atlas
Updated Branches:
  refs/heads/master da8581e90 -> e86fc944e


ATLAS-2530 trim query string before using it as name attribute for Hive process and column lineage

Signed-off-by: Madhan Neethiraj <ma...@apache.org>


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

Branch: refs/heads/master
Commit: e86fc944edff263c38b17741a68b9966050030af
Parents: da8581e
Author: Peter Gergo Barna <pb...@hortonworks.com>
Authored: Wed Apr 4 18:06:03 2018 +0200
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Thu Apr 5 15:14:31 2018 -0700

----------------------------------------------------------------------
 .../atlas/hive/hook/events/BaseHiveEvent.java   |  2 +-
 .../hive/bridge/HiveMetastoreBridgeIT.java      | 25 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/e86fc944/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
index a309eed..08c561f 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
@@ -512,7 +512,7 @@ public abstract class BaseHiveEvent {
         String      queryStr    = hookContext.getQueryPlan().getQueryStr();
 
         if (queryStr != null) {
-            queryStr = queryStr.toLowerCase();
+            queryStr = queryStr.toLowerCase().trim();
         }
 
         ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, getQualifiedName(inputs, outputs));

http://git-wip-us.apache.org/repos/asf/atlas/blob/e86fc944/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetastoreBridgeIT.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetastoreBridgeIT.java b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetastoreBridgeIT.java
index a5b1f4d..afdc7be 100644
--- a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetastoreBridgeIT.java
+++ b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetastoreBridgeIT.java
@@ -93,4 +93,29 @@ public class HiveMetastoreBridgeIT extends HiveITBase {
         assertEquals(outputs.size(), 1);
         assertEquals(outputs.get(0).getGuid(), tableId);
     }
+
+
+    @Test
+    public void testCreateTableHiveProcessNameAttribute() throws Exception {
+    	//test if \n is trimmed from name attribute of the process entity
+        String tableName = tableName();
+        String tableName2 = tableName();
+        String name = String.format("create table %s (id string)", tableName2);
+        String query = String.format("create table %s (id string);%n%n%s;", tableName, name);
+        runCommand(query);
+
+        String dbId = assertDatabaseIsRegistered(DEFAULT_DB);
+        String tableId = assertTableIsRegistered(DEFAULT_DB, tableName);
+        String tableId2 = assertTableIsRegistered(DEFAULT_DB, tableName2);
+
+        //verify lineage is created
+        String      processId      = assertEntityIsRegistered(HiveDataTypes.HIVE_PROCESS.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, getTableProcessQualifiedName(DEFAULT_DB, tableName), null);
+        AtlasEntity processsEntity = atlasClientV2.getEntityByGuid(processId).getEntity();
+
+        String      processId2      = assertEntityIsRegistered(HiveDataTypes.HIVE_PROCESS.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, getTableProcessQualifiedName(DEFAULT_DB, tableName2), null);
+        AtlasEntity processsEntity2 = atlasClientV2.getEntityByGuid(processId2).getEntity();
+        
+        assertEquals(processsEntity2.getAttribute("name"), name);
+    }
+
 }