You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2019/07/19 18:30:14 UTC

[atlas] branch branch-2.0 updated (a69166e -> 845a2a8)

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

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


    from a69166e  ATLAS-3067: fixed failure in EntityJerseyResourceIT.testUTF8()
     new 03ae2dc  ATLAS-3234: Add option in Precommit-Atlas to fail at end
     new df42363  ATLAS-3339: Exclude dom4j library from being packaged in atlas war
     new b18e66a  ATLAS-3310:- Fix create/update Relationships, after updating a bigint attribute.
     new 1b6a0c4  ATLAS-3326 Update Hbase hook/bridge to use relationship attribute and move Conversion methods to AtlasTypeUtil
     new 845a2a8  ATLAS-3335 Update Sqoop/Storm hook to use relationship attributes

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/atlas/hbase/bridge/HBaseAtlasHook.java  |  9 ++--
 .../org/apache/atlas/hbase/bridge/HBaseBridge.java |  7 ++-
 .../atlas/hive/bridge/HiveMetaStoreBridge.java     | 19 ++++----
 .../atlas/hive/hook/events/BaseHiveEvent.java      | 52 +++++-----------------
 .../atlas/hive/hook/events/CreateHiveProcess.java  |  7 +--
 .../atlas/hive/bridge/HiveMetaStoreBridgeTest.java |  3 +-
 .../org/apache/atlas/sqoop/hook/SqoopHook.java     | 14 +++---
 .../apache/atlas/storm/hook/StormAtlasHook.java    | 12 +++--
 dev-support/test-patch.sh                          |  5 +++
 .../apache/atlas/type/AtlasRelationshipType.java   | 24 ++++++++--
 .../java/org/apache/atlas/type/AtlasTypeUtil.java  | 44 ++++++++++++++++++
 pom.xml                                            |  4 +-
 .../store/graph/v2/AtlasRelationshipStoreV2.java   | 19 ++++++--
 webapp/pom.xml                                     |  4 +-
 14 files changed, 141 insertions(+), 82 deletions(-)


[atlas] 01/05: ATLAS-3234: Add option in Precommit-Atlas to fail at end

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 03ae2dc079b9d2da427cdad560dfc677a992c222
Author: Sarath Subramanian <sa...@apache.org>
AuthorDate: Wed Jul 17 12:36:09 2019 -0700

    ATLAS-3234: Add option in Precommit-Atlas to fail at end
    
    (cherry picked from commit 9f2e57f0d2717c8fd5e32fceab3edf64ce921fa8)
---
 dev-support/test-patch.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
index 2cc6062..9b10af4 100755
--- a/dev-support/test-patch.sh
+++ b/dev-support/test-patch.sh
@@ -603,6 +603,11 @@ buildAndInstall () {
     MVN_GOALS+=" -DskipITs"
   fi
 
+  if [[ $FAIL_AT_END == "true" ]]; then
+    echo "Fail at end flag set to true."
+    MVN_GOALS+=" --fail-at-end"
+  fi
+
   echo "$MVN $MVN_GOALS"
   $MVN $MVN_GOALS
 


[atlas] 02/05: ATLAS-3339: Exclude dom4j library from being packaged in atlas war

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit df4236318317c57920caa4679e4059284962ae72
Author: Sarath Subramanian <sa...@apache.org>
AuthorDate: Tue Jul 16 17:12:24 2019 -0700

    ATLAS-3339: Exclude dom4j library from being packaged in atlas war
    
    (cherry picked from commit 93addf064bf1bbfc1c847b7801845a9c7e39bc7c)
---
 pom.xml        | 4 ++--
 webapp/pom.xml | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index fb2c8e2..5d99dea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -609,7 +609,7 @@
                 <graphdb.backend.impl>org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase</graphdb.backend.impl>
                 <graph.index.backend>solr</graph.index.backend>
                 <tests.solr.embedded>true</tests.solr.embedded>
-                <distro.exclude.packages>WEB-INF/lib/je-*.jar,WEB-INF/lib/solr-test-framework-*.jar, WEB-INF/lib/jts-*.jar,WEB-INF/lib/logback-*.jar</distro.exclude.packages>
+                <distro.exclude.packages>WEB-INF/lib/je-*.jar,WEB-INF/lib/solr-test-framework-*.jar, WEB-INF/lib/jts-*.jar,WEB-INF/lib/logback-*.jar,WEB-INF/lib/dom4j-*.jar</distro.exclude.packages>
             </properties>
         </profile>
 
@@ -629,7 +629,7 @@
                 <graphdb.backend.impl>org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase</graphdb.backend.impl>
                 <graph.index.backend>solr</graph.index.backend>
                 <tests.solr.embedded>true</tests.solr.embedded>
-                <distro.exclude.packages>WEB-INF/lib/je-*.jar,WEB-INF/lib/solr-test-framework-*.jar, WEB-INF/lib/jts-*.jar,WEB-INF/lib/logback-*.jar</distro.exclude.packages>
+                <distro.exclude.packages>WEB-INF/lib/je-*.jar,WEB-INF/lib/solr-test-framework-*.jar, WEB-INF/lib/jts-*.jar,WEB-INF/lib/logback-*.jar,WEB-INF/lib/dom4j-*.jar</distro.exclude.packages>
             </properties>
         </profile>
 
diff --git a/webapp/pom.xml b/webapp/pom.xml
index 2ba65cf..1ac1b5a 100755
--- a/webapp/pom.xml
+++ b/webapp/pom.xml
@@ -54,7 +54,7 @@
                 <activeByDefault>false</activeByDefault>
             </activation>
             <properties>
-                <packages.to.exclude>WEB-INF/lib/je-*.jar</packages.to.exclude>
+                <packages.to.exclude>WEB-INF/lib/je-*.jar,WEB-INF/lib/dom4j-*.jar</packages.to.exclude>
             </properties>
         </profile>
 
@@ -501,7 +501,7 @@
                         </manifest>
                     </archive>
                     <packagingExcludes>
-                        WEB-INF/lib/junit*.jar,${packages.to.exclude}
+                        WEB-INF/lib/junit*.jar,WEB-INF/lib/dom4j-*.jar,${packages.to.exclude}
                     </packagingExcludes>
                 </configuration>
             </plugin>


[atlas] 05/05: ATLAS-3335 Update Sqoop/Storm hook to use relationship attributes

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 845a2a8b5561e964bb2c24df61aa6f553969b493
Author: Mandar Ambawane <ma...@freestoneinfotech.com>
AuthorDate: Thu Jul 18 19:15:11 2019 +0530

    ATLAS-3335 Update Sqoop/Storm hook to use relationship attributes
    
    Signed-off-by: Sarath Subramanian <sa...@apache.org>
    (cherry picked from commit 74bfe9478ed26d917d5da77e02309d8b7b4299f9)
---
 .../main/java/org/apache/atlas/sqoop/hook/SqoopHook.java   | 14 +++++++++-----
 .../java/org/apache/atlas/storm/hook/StormAtlasHook.java   | 12 ++++++++----
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java b/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
index 3ccd426..25ab7cb 100644
--- a/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
+++ b/addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
@@ -70,6 +70,10 @@ public class SqoopHook extends SqoopJobDataPublisher {
     public static final String OUTPUTS        = "outputs";
     public static final String ATTRIBUTE_DB   = "db";
 
+    public static final String RELATIONSHIP_HIVE_TABLE_DB = "hive_table_db";
+    public static final String RELATIONSHIP_DATASET_PROCESS_INPUTS = "dataset_process_inputs";
+    public static final String RELATIONSHIP_PROCESS_DATASET_OUTPUTS = "process_dataset_outputs";
+
     private static final AtlasHookImpl atlasHook;
 
     static {
@@ -129,7 +133,7 @@ public class SqoopHook extends SqoopJobDataPublisher {
 
         entHiveTable.setAttribute(AtlasClient.NAME, tableName.toLowerCase());
         entHiveTable.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, qualifiedName);
-        entHiveTable.setAttribute(ATTRIBUTE_DB, AtlasTypeUtil.getAtlasObjectId(entHiveDb));
+        entHiveTable.setRelationshipAttribute(ATTRIBUTE_DB, AtlasTypeUtil.getAtlasRelatedObjectId(entHiveDb, RELATIONSHIP_HIVE_TABLE_DB));
 
         return entHiveTable;
     }
@@ -179,11 +183,11 @@ public class SqoopHook extends SqoopJobDataPublisher {
         List<AtlasObjectId> hiveObjects  = Collections.singletonList(AtlasTypeUtil.getAtlasObjectId(entHiveTable != null ? entHiveTable : entHiveDb));
 
         if (isImportOperation(data)) {
-            entProcess.setAttribute(SqoopHook.INPUTS, sqoopObjects);
-            entProcess.setAttribute(SqoopHook.OUTPUTS, hiveObjects);
+            entProcess.setRelationshipAttribute(SqoopHook.INPUTS, AtlasTypeUtil.getAtlasRelatedObjectIdList(sqoopObjects, RELATIONSHIP_DATASET_PROCESS_INPUTS));
+            entProcess.setRelationshipAttribute(SqoopHook.OUTPUTS, AtlasTypeUtil.getAtlasRelatedObjectIdList(hiveObjects, RELATIONSHIP_PROCESS_DATASET_OUTPUTS));
         } else {
-            entProcess.setAttribute(SqoopHook.INPUTS, hiveObjects);
-            entProcess.setAttribute(SqoopHook.OUTPUTS, sqoopObjects);
+            entProcess.setRelationshipAttribute(SqoopHook.INPUTS, AtlasTypeUtil.getAtlasRelatedObjectIdList(hiveObjects, RELATIONSHIP_DATASET_PROCESS_INPUTS));
+            entProcess.setRelationshipAttribute(SqoopHook.OUTPUTS, AtlasTypeUtil.getAtlasRelatedObjectIdList(sqoopObjects, RELATIONSHIP_PROCESS_DATASET_OUTPUTS));
         }
 
         entProcess.setAttribute(SqoopHook.USER, data.getUser());
diff --git a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java
index 517a3c3..cdfdefc 100644
--- a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java
+++ b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java
@@ -67,6 +67,10 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook {
     public  static final String HBASE_NAMESPACE_DEFAULT = "default";
     public  static final String ATTRIBUTE_DB            = "db";
 
+    public static final String RELATIONSHIP_STORM_TOPOLOGY_NODES = "storm_topology_nodes";
+    public static final String RELATIONSHIP_DATASET_PROCESS_INPUTS = "dataset_process_inputs";
+    public static final String RELATIONSHIP_PROCESS_DATASET_OUTPUTS = "process_dataset_outputs";
+
     /**
      * This is the client-side hook that storm fires when a topology is added.
      *
@@ -90,7 +94,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook {
 
             if (CollectionUtils.isNotEmpty(graphNodes)) {
                 // add the connection from topology to the graph
-                topology.setAttribute("nodes", AtlasTypeUtil.getAtlasObjectIds(graphNodes));
+                topology.setRelationshipAttribute("nodes", AtlasTypeUtil.getAtlasRelatedObjectIds(graphNodes, RELATIONSHIP_STORM_TOPOLOGY_NODES));
 
                 for (AtlasEntity graphNode : graphNodes) {
                     entity.addReferredEntity(graphNode);
@@ -144,7 +148,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook {
             }
         }
 
-        topology.setAttribute("inputs", AtlasTypeUtil.getAtlasObjectIds(inputs));
+        topology.setRelationshipAttribute("inputs", AtlasTypeUtil.getAtlasRelatedObjectIds(inputs, RELATIONSHIP_DATASET_PROCESS_INPUTS));
     }
 
     private void addTopologyOutputs(StormTopology stormTopology, String topologyOwner, Map stormConf, AtlasEntity topology, AtlasEntityExtInfo entityExtInfo) {
@@ -162,7 +166,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook {
             }
         }
 
-        topology.setAttribute("outputs", AtlasTypeUtil.getAtlasObjectIds(outputs));
+        topology.setRelationshipAttribute("outputs", AtlasTypeUtil.getAtlasRelatedObjectIds(outputs, RELATIONSHIP_PROCESS_DATASET_OUTPUTS));
     }
 
     private AtlasEntity addDataSet(String dataSetType, String topologyOwner, Serializable instance, Map stormConf, AtlasEntityExtInfo entityExtInfo) {
@@ -272,7 +276,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook {
                     ret = new AtlasEntity("hive_table");
 
                     ret.setAttribute(AtlasClient.NAME, tblName);
-                    ret.setAttribute(ATTRIBUTE_DB, AtlasTypeUtil.getAtlasObjectId(dbEntity));
+                    ret.setRelationshipAttribute(ATTRIBUTE_DB, AtlasTypeUtil.getAtlasRelatedObjectId(dbEntity, "hive_table_db"));
                     ret.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, HiveMetaStoreBridge.getTableQualifiedName(metadataNamespace, dbName, tblName));
                 }
             }


[atlas] 04/05: ATLAS-3326 Update Hbase hook/bridge to use relationship attribute and move Conversion methods to AtlasTypeUtil

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1b6a0c4f6347b36cbd6a7bbbf8586927b157481d
Author: Mandar Ambawane <ma...@freestoneinfotech.com>
AuthorDate: Mon Jul 15 16:36:42 2019 +0530

    ATLAS-3326 Update Hbase hook/bridge to use relationship attribute and move Conversion methods to AtlasTypeUtil
    
    Signed-off-by: nixonrodrigues <ni...@apache.org>
    (cherry picked from commit ca62d8659db632954ed28e35f3a5e7d27d3fe8b4)
---
 .../apache/atlas/hbase/bridge/HBaseAtlasHook.java  |  9 ++--
 .../org/apache/atlas/hbase/bridge/HBaseBridge.java |  7 ++-
 .../atlas/hive/bridge/HiveMetaStoreBridge.java     | 19 ++++----
 .../atlas/hive/hook/events/BaseHiveEvent.java      | 52 +++++-----------------
 .../atlas/hive/hook/events/CreateHiveProcess.java  |  7 +--
 .../atlas/hive/bridge/HiveMetaStoreBridgeTest.java |  3 +-
 .../java/org/apache/atlas/type/AtlasTypeUtil.java  | 44 ++++++++++++++++++
 7 files changed, 80 insertions(+), 61 deletions(-)

diff --git a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
index 6d062e2..26be9b3 100644
--- a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
+++ b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
@@ -103,6 +103,9 @@ public class HBaseAtlasHook extends AtlasHook {
 
     private static final String REFERENCEABLE_ATTRIBUTE_NAME = "qualifiedName";
 
+    public static final String RELATIONSHIP_HBASE_TABLE_COLUMN_FAMILIES = "hbase_table_column_families";
+    public static final String RELATIONSHIP_HBASE_TABLE_NAMESPACE = "hbase_table_namespace";
+
     private static volatile HBaseAtlasHook me;
 
     public enum OPERATION {
@@ -212,7 +215,7 @@ public class HBaseAtlasHook extends AtlasHook {
         AtlasEntity       table          = buildTable(hbaseOperationContext, nameSpace);
         List<AtlasEntity> columnFamilies = buildColumnFamilies(hbaseOperationContext, nameSpace, table);
 
-        table.setAttribute(ATTR_COLUMNFAMILIES, AtlasTypeUtil.getAtlasObjectIds(columnFamilies));
+        table.setRelationshipAttribute(ATTR_COLUMNFAMILIES, AtlasTypeUtil.getAtlasRelatedObjectIds(columnFamilies, RELATIONSHIP_HBASE_TABLE_COLUMN_FAMILIES));
 
         AtlasEntitiesWithExtInfo entities = new AtlasEntitiesWithExtInfo(table);
 
@@ -392,7 +395,7 @@ public class HBaseAtlasHook extends AtlasHook {
         table.setAttribute(ATTR_OWNER, hbaseOperationContext.getOwner());
         table.setAttribute(ATTR_DESCRIPTION, tableName);
         table.setAttribute(ATTR_PARAMETERS, hbaseOperationContext.getHbaseConf());
-        table.setAttribute(ATTR_NAMESPACE, AtlasTypeUtil.getAtlasObjectId(nameSpace));
+        table.setRelationshipAttribute(ATTR_NAMESPACE, AtlasTypeUtil.getAtlasRelatedObjectId(nameSpace, RELATIONSHIP_HBASE_TABLE_NAMESPACE));
 
         TableDescriptor tableDescriptor = hbaseOperationContext.gethTableDescriptor();
         if (tableDescriptor != null) {
@@ -451,7 +454,7 @@ public class HBaseAtlasHook extends AtlasHook {
         columnFamily.setAttribute(ATTR_DESCRIPTION, columnFamilyName);
         columnFamily.setAttribute(REFERENCEABLE_ATTRIBUTE_NAME, columnFamilyQName);
         columnFamily.setAttribute(ATTR_OWNER, hbaseOperationContext.getOwner());
-        columnFamily.setAttribute(ATTR_TABLE, AtlasTypeUtil.getAtlasObjectId(table));
+        columnFamily.setRelationshipAttribute(ATTR_TABLE, AtlasTypeUtil.getAtlasRelatedObjectId(table, RELATIONSHIP_HBASE_TABLE_COLUMN_FAMILIES));
 
         if (columnFamilyDescriptor!= null) {
             columnFamily.setAttribute(ATTR_CF_BLOCK_CACHE_ENABLED, columnFamilyDescriptor.isBlockCacheEnabled());
diff --git a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java
index 4a4b4d9..fde70f1 100644
--- a/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java
+++ b/addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java
@@ -430,8 +430,7 @@ public class HBaseBridge {
                     cfIDs.add(AtlasTypeUtil.getAtlasObjectId(cfEntity.getEntity()));
                 }
             }
-
-            tableEntity.setAttribute(COLUMN_FAMILIES, cfIDs);
+            tableEntity.setRelationshipAttribute(COLUMN_FAMILIES, AtlasTypeUtil.getAtlasRelatedObjectIdList(cfIDs, HBaseAtlasHook.RELATIONSHIP_HBASE_TABLE_COLUMN_FAMILIES));
         }
 
         return ret;
@@ -548,7 +547,7 @@ public class HBaseBridge {
 
         ret.setAttribute(QUALIFIED_NAME, tableQualifiedName);
         ret.setAttribute(CLUSTERNAME, metadataNamespace);
-        ret.setAttribute(NAMESPACE, AtlasTypeUtil.getAtlasObjectId(nameSpaceEntity));
+        ret.setRelationshipAttribute(NAMESPACE, AtlasTypeUtil.getAtlasRelatedObjectId(nameSpaceEntity, HBaseAtlasHook.RELATIONSHIP_HBASE_TABLE_NAMESPACE));
         ret.setAttribute(NAME, tableName);
         ret.setAttribute(DESCRIPTION_ATTR, tableName);
         ret.setAttribute(OWNER, owner);
@@ -577,7 +576,7 @@ public class HBaseBridge {
 
         ret.setAttribute(QUALIFIED_NAME, cfQualifiedName);
         ret.setAttribute(CLUSTERNAME, metadataNamespace);
-        ret.setAttribute(TABLE, tableId);
+        ret.setRelationshipAttribute(TABLE, AtlasTypeUtil.getAtlasRelatedObjectId(tableId, HBaseAtlasHook.RELATIONSHIP_HBASE_TABLE_COLUMN_FAMILIES));
         ret.setAttribute(NAME, cfName);
         ret.setAttribute(DESCRIPTION_ATTR, cfName);
         ret.setAttribute(OWNER, owner);
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
index a61a3e6..2f1bb0e 100755
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
@@ -20,6 +20,7 @@ package org.apache.atlas.hive.bridge;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.sun.jersey.api.client.ClientResponse;
+import org.apache.atlas.type.AtlasTypeUtil;
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasClientV2;
 import org.apache.atlas.AtlasServiceException;
@@ -363,8 +364,8 @@ public class HiveMetaStoreBridge {
                     processInst.setAttribute(ATTRIBUTE_QUALIFIED_NAME, processQualifiedName);
                     processInst.setAttribute(ATTRIBUTE_NAME, query);
                     processInst.setAttribute(ATTRIBUTE_CLUSTER_NAME, metadataNamespace);
-                    processInst.setRelationshipAttribute(ATTRIBUTE_INPUTS, Collections.singletonList(getAtlasRelatedObjectId(pathInst, RELATIONSHIP_DATASET_PROCESS_INPUTS)));
-                    processInst.setRelationshipAttribute(ATTRIBUTE_OUTPUTS, Collections.singletonList(getAtlasRelatedObjectId(tableInst, RELATIONSHIP_PROCESS_DATASET_OUTPUTS)));
+                    processInst.setRelationshipAttribute(ATTRIBUTE_INPUTS, Collections.singletonList(AtlasTypeUtil.getAtlasRelatedObjectId(pathInst, RELATIONSHIP_DATASET_PROCESS_INPUTS)));
+                    processInst.setRelationshipAttribute(ATTRIBUTE_OUTPUTS, Collections.singletonList(AtlasTypeUtil.getAtlasRelatedObjectId(tableInst, RELATIONSHIP_PROCESS_DATASET_OUTPUTS)));
                     processInst.setAttribute(ATTRIBUTE_USER_NAME, table.getOwner());
                     processInst.setAttribute(ATTRIBUTE_START_TIME, now);
                     processInst.setAttribute(ATTRIBUTE_END_TIME, now);
@@ -590,7 +591,7 @@ public class HiveMetaStoreBridge {
         long        createTime         = BaseHiveEvent.getTableCreateTime(hiveTable);
         long        lastAccessTime     = hiveTable.getLastAccessTime() > 0 ? hiveTable.getLastAccessTime() : createTime;
 
-        tableEntity.setRelationshipAttribute(ATTRIBUTE_DB, getAtlasRelatedObjectId(database, RELATIONSHIP_HIVE_TABLE_DB));
+        tableEntity.setRelationshipAttribute(ATTRIBUTE_DB, AtlasTypeUtil.getAtlasRelatedObjectId(database, RELATIONSHIP_HIVE_TABLE_DB));
         tableEntity.setAttribute(ATTRIBUTE_QUALIFIED_NAME, tableQualifiedName);
         tableEntity.setAttribute(ATTRIBUTE_NAME, hiveTable.getTableName().toLowerCase());
         tableEntity.setAttribute(ATTRIBUTE_OWNER, hiveTable.getOwner());
@@ -611,13 +612,13 @@ public class HiveMetaStoreBridge {
             tableEntity.setAttribute(ATTRIBUTE_VIEW_EXPANDED_TEXT, hiveTable.getViewExpandedText());
         }
 
-        AtlasEntity       sdEntity = toStorageDescEntity(hiveTable.getSd(), tableQualifiedName, getStorageDescQFName(tableQualifiedName), BaseHiveEvent.getObjectId(tableEntity));
+        AtlasEntity       sdEntity = toStorageDescEntity(hiveTable.getSd(), tableQualifiedName, getStorageDescQFName(tableQualifiedName), AtlasTypeUtil.getObjectId(tableEntity));
         List<AtlasEntity> partKeys = toColumns(hiveTable.getPartitionKeys(), tableEntity, RELATIONSHIP_HIVE_TABLE_PART_KEYS);
         List<AtlasEntity> columns  = toColumns(hiveTable.getCols(), tableEntity, RELATIONSHIP_HIVE_TABLE_COLUMNS);
 
-        tableEntity.setRelationshipAttribute(ATTRIBUTE_STORAGEDESC, getAtlasRelatedObjectId(sdEntity, RELATIONSHIP_HIVE_TABLE_STORAGE_DESC));
-        tableEntity.setRelationshipAttribute(ATTRIBUTE_PARTITION_KEYS, getObjectIdsWithRelationshipType(partKeys, RELATIONSHIP_HIVE_TABLE_PART_KEYS));
-        tableEntity.setRelationshipAttribute(ATTRIBUTE_COLUMNS, getObjectIdsWithRelationshipType(columns, RELATIONSHIP_HIVE_TABLE_COLUMNS));
+        tableEntity.setRelationshipAttribute(ATTRIBUTE_STORAGEDESC, AtlasTypeUtil.getAtlasRelatedObjectId(sdEntity, RELATIONSHIP_HIVE_TABLE_STORAGE_DESC));
+        tableEntity.setRelationshipAttribute(ATTRIBUTE_PARTITION_KEYS, AtlasTypeUtil.getAtlasRelatedObjectIds(partKeys, RELATIONSHIP_HIVE_TABLE_PART_KEYS));
+        tableEntity.setRelationshipAttribute(ATTRIBUTE_COLUMNS, AtlasTypeUtil.getAtlasRelatedObjectIds(columns, RELATIONSHIP_HIVE_TABLE_COLUMNS));
 
         table.addReferredEntity(database);
         table.addReferredEntity(sdEntity);
@@ -642,7 +643,7 @@ public class HiveMetaStoreBridge {
     private AtlasEntity toStorageDescEntity(StorageDescriptor storageDesc, String tableQualifiedName, String sdQualifiedName, AtlasObjectId tableId ) throws AtlasHookException {
         AtlasEntity ret = new AtlasEntity(HiveDataTypes.HIVE_STORAGEDESC.getName());
 
-        ret.setRelationshipAttribute(ATTRIBUTE_TABLE, getAtlasRelatedObjectId(tableId, RELATIONSHIP_HIVE_TABLE_STORAGE_DESC));
+        ret.setRelationshipAttribute(ATTRIBUTE_TABLE, AtlasTypeUtil.getAtlasRelatedObjectId(tableId, RELATIONSHIP_HIVE_TABLE_STORAGE_DESC));
         ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, sdQualifiedName);
         ret.setAttribute(ATTRIBUTE_PARAMETERS, storageDesc.getParameters());
         ret.setAttribute(ATTRIBUTE_LOCATION, HdfsNameServiceResolver.getPathWithNameServiceID(storageDesc.getLocation()));
@@ -698,7 +699,7 @@ public class HiveMetaStoreBridge {
 
             AtlasEntity column = new AtlasEntity(HiveDataTypes.HIVE_COLUMN.getName());
 
-            column.setRelationshipAttribute(ATTRIBUTE_TABLE, getAtlasRelatedObjectId(table, relationshipType));
+            column.setRelationshipAttribute(ATTRIBUTE_TABLE, AtlasTypeUtil.getAtlasRelatedObjectId(table, relationshipType));
             column.setAttribute(ATTRIBUTE_QUALIFIED_NAME, getColumnQualifiedName((String) table.getAttribute(ATTRIBUTE_QUALIFIED_NAME), fs.getName()));
             column.setAttribute(ATTRIBUTE_NAME, fs.getName());
             column.setAttribute(ATTRIBUTE_OWNER, table.getAttribute(ATTRIBUTE_OWNER));
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 1a6e070..fe0a140 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
@@ -209,36 +209,6 @@ public abstract class BaseHiveEvent {
     }
 
 
-    public static AtlasRelatedObjectId getAtlasRelatedObjectId(AtlasEntity entity, String relationshipType) {
-        return getAtlasRelatedObjectId(getObjectId(entity), relationshipType);
-    }
-
-    public static AtlasRelatedObjectId getAtlasRelatedObjectId(AtlasObjectId objectId, String relationShipType) {
-        AtlasRelatedObjectId atlasRelatedObjectId = new AtlasRelatedObjectId(objectId, relationShipType);
-        return atlasRelatedObjectId;
-    }
-
-    public static List<AtlasRelatedObjectId> getObjectIdsWithRelationshipType(List<AtlasEntity> entities,String relationshipType) {
-        final List<AtlasRelatedObjectId> ret;
-        if (CollectionUtils.isNotEmpty(entities)) {
-            ret = new ArrayList<>(entities.size());
-            for (AtlasEntity entity : entities) {
-                ret.add(getAtlasRelatedObjectId(entity, relationshipType));
-            }
-        } else {
-            ret = Collections.emptyList();
-        }
-        return ret;
-    }
-
-
-    public static AtlasObjectId getObjectId(AtlasEntity entity) {
-        String        qualifiedName = (String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME);
-        AtlasObjectId ret           = new AtlasObjectId(entity.getGuid(), entity.getTypeName(), Collections.singletonMap(ATTRIBUTE_QUALIFIED_NAME, qualifiedName));
-
-        return ret;
-    }
-
     public static List<AtlasObjectId> getObjectIds(List<AtlasEntity> entities) {
         final List<AtlasObjectId> ret;
 
@@ -246,7 +216,7 @@ public abstract class BaseHiveEvent {
             ret = new ArrayList<>(entities.size());
 
             for (AtlasEntity entity : entities) {
-                ret.add(getObjectId(entity));
+                ret.add(AtlasTypeUtil.getObjectId(entity));
             }
         } else {
             ret = Collections.emptyList();
@@ -403,7 +373,7 @@ public abstract class BaseHiveEvent {
             }
         }
 
-        AtlasEntity ret = toTableEntity(getObjectId(dbEntity), table, entityExtInfo);
+        AtlasEntity ret = toTableEntity(AtlasTypeUtil.getObjectId(dbEntity), table, entityExtInfo);
 
         return ret;
     }
@@ -459,7 +429,7 @@ public abstract class BaseHiveEvent {
                 if (pruneTable) {
                     LOG.info("ignoring details of table {}", tblQualifiedName);
                 } else {
-                    AtlasObjectId     tableId       = getObjectId(ret);
+                    AtlasObjectId     tableId       = AtlasTypeUtil.getObjectId(ret);
                     AtlasEntity       sd            = getStorageDescEntity(tableId, table);
                     List<AtlasEntity> partitionKeys = getColumnEntities(tableId, table, table.getPartitionKeys(), RELATIONSHIP_HIVE_TABLE_PART_KEYS);
                     List<AtlasEntity> columns       = getColumnEntities(tableId, table, table.getCols(), RELATIONSHIP_HIVE_TABLE_COLUMNS);
@@ -483,9 +453,9 @@ public abstract class BaseHiveEvent {
                     }
 
 
-                    ret.setRelationshipAttribute(ATTRIBUTE_STORAGEDESC, getAtlasRelatedObjectId(sd, RELATIONSHIP_HIVE_TABLE_STORAGE_DESC));
-                    ret.setRelationshipAttribute(ATTRIBUTE_PARTITION_KEYS, getObjectIdsWithRelationshipType(partitionKeys, RELATIONSHIP_HIVE_TABLE_PART_KEYS));
-                    ret.setRelationshipAttribute(ATTRIBUTE_COLUMNS, getObjectIdsWithRelationshipType(columns, RELATIONSHIP_HIVE_TABLE_COLUMNS));
+                    ret.setRelationshipAttribute(ATTRIBUTE_STORAGEDESC, AtlasTypeUtil.getAtlasRelatedObjectId(sd, RELATIONSHIP_HIVE_TABLE_STORAGE_DESC));
+                    ret.setRelationshipAttribute(ATTRIBUTE_PARTITION_KEYS, AtlasTypeUtil.getAtlasRelatedObjectIds(partitionKeys, RELATIONSHIP_HIVE_TABLE_PART_KEYS));
+                    ret.setRelationshipAttribute(ATTRIBUTE_COLUMNS, AtlasTypeUtil.getAtlasRelatedObjectIds(columns, RELATIONSHIP_HIVE_TABLE_COLUMNS));
                 }
 
                 context.putEntity(tblQualifiedName, ret);
@@ -630,7 +600,7 @@ public abstract class BaseHiveEvent {
 
                 ret = new AtlasEntity(AWS_S3_PSEUDO_DIR);
 
-                ret.setRelationshipAttribute(ATTRIBUTE_BUCKET, getAtlasRelatedObjectId(bucketEntity, RELATIONSHIP_AWS_S3_BUCKET_S3_PSEUDO_DIRS));
+                ret.setRelationshipAttribute(ATTRIBUTE_BUCKET, AtlasTypeUtil.getAtlasRelatedObjectId(bucketEntity, RELATIONSHIP_AWS_S3_BUCKET_S3_PSEUDO_DIRS));
                 ret.setAttribute(ATTRIBUTE_OBJECT_PREFIX, Path.getPathWithoutSchemeAndAuthority(path).toString().toLowerCase());
                 ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, pathQualifiedName);
                 ret.setAttribute(ATTRIBUTE_NAME, Path.getPathWithoutSchemeAndAuthority(path).toString().toLowerCase());
@@ -678,8 +648,8 @@ public abstract class BaseHiveEvent {
         }
 
         ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, getQualifiedName(inputs, outputs));
-        ret.setRelationshipAttribute(ATTRIBUTE_INPUTS, getObjectIdsWithRelationshipType(inputs, RELATIONSHIP_DATASET_PROCESS_INPUTS));
-        ret.setRelationshipAttribute(ATTRIBUTE_OUTPUTS, getObjectIdsWithRelationshipType(outputs, RELATIONSHIP_PROCESS_DATASET_OUTPUTS));
+        ret.setRelationshipAttribute(ATTRIBUTE_INPUTS, AtlasTypeUtil.getAtlasRelatedObjectIds(inputs, RELATIONSHIP_DATASET_PROCESS_INPUTS));
+        ret.setRelationshipAttribute(ATTRIBUTE_OUTPUTS, AtlasTypeUtil.getAtlasRelatedObjectIds(outputs, RELATIONSHIP_PROCESS_DATASET_OUTPUTS));
         ret.setAttribute(ATTRIBUTE_NAME, queryStr);
         ret.setAttribute(ATTRIBUTE_OPERATION_TYPE, getOperationName());
 
@@ -726,7 +696,7 @@ public abstract class BaseHiveEvent {
     }
 
     protected AtlasEntity createHiveDDLEntity(AtlasEntity dbOrTable, boolean excludeEntityGuid) {
-        AtlasObjectId objId   = BaseHiveEvent.getObjectId(dbOrTable);
+        AtlasObjectId objId   = AtlasTypeUtil.getObjectId(dbOrTable);
         AtlasEntity   hiveDDL = null;
 
         if (excludeEntityGuid) {
@@ -1004,7 +974,7 @@ public abstract class BaseHiveEvent {
             ret.setAttribute(ATTRIBUTE_NAME, hbaseTableName);
             ret.setAttribute(ATTRIBUTE_URI, hbaseTableName);
 
-            AtlasRelatedObjectId objIdRelatedObject = new AtlasRelatedObjectId(getObjectId(nsEntity), RELATIONSHIP_HBASE_TABLE_NAMESPACE);
+            AtlasRelatedObjectId objIdRelatedObject = new AtlasRelatedObjectId(AtlasTypeUtil.getObjectId(nsEntity), RELATIONSHIP_HBASE_TABLE_NAMESPACE);
 
             ret.setRelationshipAttribute(ATTRIBUTE_NAMESPACE, objIdRelatedObject);
             ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, getHBaseTableQualifiedName(metadataNamespace, hbaseNameSpace, hbaseTableName));
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java
index 6b050d4..82df576 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java
@@ -18,6 +18,7 @@
 
 package org.apache.atlas.hive.hook.events;
 
+import org.apache.atlas.type.AtlasTypeUtil;
 import org.apache.atlas.hive.hook.AtlasHiveHookContext;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
@@ -207,9 +208,9 @@ public class CreateHiveProcess extends BaseHiveEvent {
 
             columnLineageProcess.setAttribute(ATTRIBUTE_NAME, hiveProcess.getAttribute(ATTRIBUTE_QUALIFIED_NAME) + ":" + outputColumn.getAttribute(ATTRIBUTE_NAME));
             columnLineageProcess.setAttribute(ATTRIBUTE_QUALIFIED_NAME, hiveProcess.getAttribute(ATTRIBUTE_QUALIFIED_NAME) + ":" + outputColumn.getAttribute(ATTRIBUTE_NAME));
-            columnLineageProcess.setRelationshipAttribute(ATTRIBUTE_INPUTS, getObjectIdsWithRelationshipType(inputColumns, BaseHiveEvent.RELATIONSHIP_DATASET_PROCESS_INPUTS));
-            columnLineageProcess.setRelationshipAttribute(ATTRIBUTE_OUTPUTS, Collections.singletonList(getAtlasRelatedObjectId(outputColumn, BaseHiveEvent.RELATIONSHIP_PROCESS_DATASET_OUTPUTS)));
-            columnLineageProcess.setRelationshipAttribute(ATTRIBUTE_QUERY, getAtlasRelatedObjectId(hiveProcess, BaseHiveEvent.RELATIONSHIP_HIVE_PROCESS_COLUMN_LINEAGE));
+            columnLineageProcess.setRelationshipAttribute(ATTRIBUTE_INPUTS, AtlasTypeUtil.getAtlasRelatedObjectIds(inputColumns, BaseHiveEvent.RELATIONSHIP_DATASET_PROCESS_INPUTS));
+            columnLineageProcess.setRelationshipAttribute(ATTRIBUTE_OUTPUTS, Collections.singletonList(AtlasTypeUtil.getAtlasRelatedObjectId(outputColumn, BaseHiveEvent.RELATIONSHIP_PROCESS_DATASET_OUTPUTS)));
+            columnLineageProcess.setRelationshipAttribute(ATTRIBUTE_QUERY, AtlasTypeUtil.getAtlasRelatedObjectId(hiveProcess, BaseHiveEvent.RELATIONSHIP_HIVE_PROCESS_COLUMN_LINEAGE));
             columnLineageProcess.setAttribute(ATTRIBUTE_DEPENDENCY_TYPE, entry.getValue().getType());
             columnLineageProcess.setAttribute(ATTRIBUTE_EXPRESSION, entry.getValue().getExpr());
 
diff --git a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java
index 4403aaf..bdf8578 100644
--- a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java
+++ b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java
@@ -24,6 +24,7 @@ import org.apache.atlas.AtlasServiceException;
 import org.apache.atlas.hive.model.HiveDataTypes;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.EntityMutationResponse;
+import org.apache.atlas.type.AtlasTypeUtil;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.api.Database;
@@ -293,7 +294,7 @@ public class HiveMetaStoreBridgeTest {
     private AtlasEntity createTableReference() {
         AtlasEntity tableEntity = new AtlasEntity(HiveDataTypes.HIVE_TABLE.getName());
         AtlasEntity sdEntity = new AtlasEntity(HiveDataTypes.HIVE_STORAGEDESC.getName());
-        tableEntity.setAttribute(ATTRIBUTE_STORAGEDESC, getObjectId(sdEntity));
+        tableEntity.setAttribute(ATTRIBUTE_STORAGEDESC, AtlasTypeUtil.getObjectId(sdEntity));
         return tableEntity;
     }
 
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
index 6ac176d..0883d54 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
@@ -67,6 +67,8 @@ public class AtlasTypeUtil {
     private static final String InvalidTypeNameErrorMessage      = "Name must consist of a letter followed by a sequence of [ letter, number, '_' ] characters.";
     private static final String InvalidTraitTypeNameErrorMessage = "Name must consist of a letter followed by a sequence of [ letter,  number, '_', '.' ] characters.";
 
+    public static final String ATTRIBUTE_QUALIFIED_NAME = "qualifiedName";
+
     static {
         Collections.addAll(ATLAS_BUILTIN_TYPENAMES, AtlasBaseTypeDef.ATLAS_BUILTIN_TYPES);
     }
@@ -468,6 +470,48 @@ public class AtlasTypeUtil {
         return ret;
     }
 
+    public static AtlasRelatedObjectId getAtlasRelatedObjectId(AtlasEntity entity, String relationshipType) {
+        return getAtlasRelatedObjectId(getObjectId(entity), relationshipType);
+    }
+
+    public static AtlasRelatedObjectId getAtlasRelatedObjectId(AtlasObjectId objectId, String relationShipType) {
+        AtlasRelatedObjectId atlasRelatedObjectId = new AtlasRelatedObjectId(objectId, relationShipType);
+        return atlasRelatedObjectId;
+    }
+
+    public static List<AtlasRelatedObjectId> getAtlasRelatedObjectIds(List<AtlasEntity> entities, String relationshipType) {
+        final List<AtlasRelatedObjectId> ret;
+        if (CollectionUtils.isNotEmpty(entities)) {
+            ret = new ArrayList<>(entities.size());
+            for (AtlasEntity entity : entities) {
+                ret.add(getAtlasRelatedObjectId(entity, relationshipType));
+            }
+        } else {
+            ret = Collections.emptyList();
+        }
+        return ret;
+    }
+
+    public static List<AtlasRelatedObjectId> getAtlasRelatedObjectIdList(List<AtlasObjectId> atlasObjectIds, String relationshipType) {
+        final List<AtlasRelatedObjectId> ret;
+        if (CollectionUtils.isNotEmpty(atlasObjectIds)) {
+            ret = new ArrayList<>(atlasObjectIds.size());
+            for (AtlasObjectId atlasObjectId : atlasObjectIds) {
+                ret.add(getAtlasRelatedObjectId(atlasObjectId, relationshipType));
+            }
+        } else {
+            ret = Collections.emptyList();
+        }
+        return ret;
+    }
+
+    public static AtlasObjectId getObjectId(AtlasEntity entity) {
+        String qualifiedName = (String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME);
+        AtlasObjectId ret = new AtlasObjectId(entity.getGuid(), entity.getTypeName(), Collections.singletonMap(ATTRIBUTE_QUALIFIED_NAME, qualifiedName));
+
+        return ret;
+    }
+
     public static boolean isValidGuid(AtlasObjectId objId) {
         return isValidGuid(objId.getGuid());
     }


[atlas] 03/05: ATLAS-3310:- Fix create/update Relationships, after updating a bigint attribute.

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b18e66ac77a7fd5a77edbb7406be9c31211fa5af
Author: mayanknj <ma...@freestoneinfotech.com>
AuthorDate: Tue Jul 16 18:49:40 2019 +0530

    ATLAS-3310:- Fix create/update Relationships, after updating a bigint attribute.
    
    (cherry picked from commit 7fcf04159887d4719631e8e3d54f4297e17f4c4d)
---
 .../apache/atlas/type/AtlasRelationshipType.java   | 24 ++++++++++++++++++----
 .../store/graph/v2/AtlasRelationshipStoreV2.java   | 19 +++++++++++++----
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java b/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
index 98071b2..6d1c64b 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
@@ -20,6 +20,7 @@ package org.apache.atlas.type;
 
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.instance.AtlasObjectId;
 import org.apache.atlas.model.instance.AtlasRelationship;
 import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
 import org.apache.atlas.model.typedef.AtlasRelationshipDef;
@@ -242,14 +243,29 @@ public class AtlasRelationshipType extends AtlasStructType {
      * @throws AtlasBaseException
      */
     private boolean validateRelationship(AtlasRelationship relationship) {
-        String end1TypeName = relationship.getEnd1() != null ? relationship.getEnd1().getTypeName() : null;
-        String end2TypeName = relationship.getEnd2() != null ? relationship.getEnd2().getTypeName() : null;
 
-        if (StringUtils.isNotEmpty(end1TypeName) && StringUtils.isNotEmpty(end2TypeName)) {
-            return end1Type.isTypeOrSuperTypeOf(end1TypeName) && end2Type.isTypeOrSuperTypeOf(end2TypeName) && super.isValidValue(relationship);
+        AtlasObjectId end1 = relationship.getEnd1();
+        AtlasObjectId end2 = relationship.getEnd2();
+
+        if (end1 != null && end2 != null) {
+
+            String end1TypeName = end1.getTypeName();
+            String end2TypeName = end2.getTypeName();
+
+            if (StringUtils.isNotEmpty(end1TypeName) && StringUtils.isNotEmpty(end2TypeName)) {
+
+                return end1Type.isTypeOrSuperTypeOf(end1TypeName) && end2Type.isTypeOrSuperTypeOf(end2TypeName) && super.isValidValue(relationship);
+
+            } else {
+
+                return StringUtils.isNotEmpty(end1.getGuid()) && StringUtils.isNotEmpty(end2.getGuid());
+
+            }
+
         }
 
         return false;
+
     }
 
     /**
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
index 54059e8..1c8b057 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
@@ -192,7 +192,16 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
             }
         }
 
-        validateRelationship(end1Vertex, end2Vertex, edgeType, relationship.getAttributes());
+        boolean relationshipTypeNotExists = false;
+        if (StringUtils.isEmpty(relationship.getTypeName())) {
+            relationship.setTypeName(edgeType);
+            relationshipTypeNotExists = true;
+        }
+        validateRelationship(end1Vertex, end2Vertex, relationship);
+
+        if (relationshipTypeNotExists) {
+            relationship.setTypeName(null);
+        }
 
         AtlasRelationship ret = updateRelationship(edge, relationship);
         sendNotifications(ret, OperationType.RELATIONSHIP_UPDATE);
@@ -337,7 +346,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
         AtlasEdge ret;
 
         try {
-            validateRelationship(end1Vertex, end2Vertex, relationship.getTypeName(), relationship.getAttributes());
+            validateRelationship(end1Vertex, end2Vertex, relationship);
 
             String relationshipLabel = getRelationshipEdgeLabel(end1Vertex, end2Vertex, relationship.getTypeName());
 
@@ -623,7 +632,10 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
         validateAndNormalize(relationship);
     }
 
-    private void validateRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, String relationshipName, Map<String, Object> attributes) throws AtlasBaseException {
+    private void validateRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex,  AtlasRelationship relationship) throws AtlasBaseException {
+
+        String relationshipName = relationship.getTypeName();
+
         AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipName);
 
         if (relationshipType == null) {
@@ -654,7 +666,6 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
         }
 
         List<String>      messages     = new ArrayList<>();
-        AtlasRelationship relationship = new AtlasRelationship(relationshipName, attributes);
 
         relationshipType.validateValue(relationship, relationshipName, messages);